- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
目前的流程似乎可以解决:
process(sel, X)
begin
-- set all to 0
mux_out <= (others => zero);
-- Set input in correct line
mux_out(to_integer(unsigned(sel))) <= X;
end process;
我会用TestBench测试更多的案例,并将结果写在这里,再次感谢大家的帮助:)
==== 上一篇文章 =======我已经通过以下 Paebbles 示例实现了 DEMUX:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.MATH_REAL.ALL;
use IEEE.NUMERIC_STD.ALL;
entity DeMUX_1toX_N_bits is
generic (
PORTS : POSITIVE := 4;
BITS : POSITIVE := 8 );
port (
sel : in STD_LOGIC_VECTOR(integer(ceil(log2(real(PORTS)))) - 1 downto 0);
X : in STD_LOGIC_VECTOR(BITS - 1 downto 0);
Y : out STD_LOGIC_VECTOR((BITS * PORTS) - 1 downto 0)
);
end;
architecture rtl of DeMUX_1toX_N_bits is
type T_SLVV is array(NATURAL range <>) of STD_LOGIC_VECTOR(BITS - 1 downto 0);
signal mux_out : T_SLVV(PORTS - 1 downto 0);
begin
gen : for i in 0 to PORTS - 1 generate
-- connect Output FLAT VECTOR to the correct T_SLVV lines
Y(((i + 1) * BITS) - 1 downto (i * BITS)) <= mux_out(i);
end generate;
mux_out(to_integer(unsigned(sel))) <= X;
end;
综合工具告诉我“找到了信号 mux_out<3><6> 的 1 位锁存器。锁存器可能是由不完整的 case 或 if 语句生成的。我们不建议在 FPGA/CPLD 设计中使用锁存器,因为它们可能会导致计时问题。”
所以为了解决这个问题,我应该显式地将“0”分配给所有其他输出位?
再次感谢您的帮助:)这种编码方式非常强大,但也很复杂:)
================== 上一篇文章 ====
我正在作为大学实验室开发一个 VHDL 项目(针对 FPGA)。我陷入了数据大小和端口数量参数化的多路复用器和多路分配器的设计上。特别是我找不到编写动态代码的方法(With/Select 语句?)
我想到的是这样的:
use IEEE.STD_LOGIC_1164.ALL;
entity generic_mux is
GENERIC ( inputs: INTEGER := 4; -- number of inputs
size : INTEGER := 8); -- size of each input
Port (
-- ??? how can i define the input data ports if i don't know the exact number?
);
end generic_mux;
architecture arc of generic_mux is
begin
-- how can i use the select as an address? The With/Select needs a
-- defined number of cases...
-- ???
end arc;
预先感谢您的帮助。
最佳答案
使用 VHDL-2008 可以这样做:
library ieee;
use ieee.std_logic_1164.all;
package mux_p is
type slv_array_t is array (natural range <>) of std_logic_vector;
end package;
package body mux_p is
end package body;
library ieee;
use ieee.std_logic_1164.all;
use work.mux_p;
entity mux is
generic(
LEN : natural; -- Bits in each input
NUM : natural); -- Number of inputs
port(
v_i : in mux_p.slv_array_t(0 to NUM - 1)(LEN - 1 downto 0);
sel_i : in natural range 0 to NUM - 1;
z_o : out std_logic_vector(LEN - 1 downto 0));
end entity;
architecture syn of mux is
begin
z_o <= v_i(sel_i);
end architecture;
sel_i
也应该是 std_logic_vector
,其长度源自 NUM
,但上面显示的是与多路复用器相关的代码.
多路复用器的使用示例可以是:
library ieee;
use ieee.std_logic_1164.all;
entity mdl is
port(
a_i : in std_logic_vector(1 downto 0);
b_i : in std_logic_vector(1 downto 0);
c_i : in std_logic_vector(1 downto 0);
sel_i : in natural;
z_o : out std_logic_vector(1 downto 0));
end entity;
architecture syn of mdl is
begin
mux_e : entity work.mux
generic map(
LEN => 2,
NUM => 3)
port map(
v_i(0) => a_i,
v_i(1) => b_i,
v_i(2) => c_i,
sel_i => sel_i,
z_o => z_o);
end architecture;
关于generics - 使用泛型的通用 MUX 和 DEMUX,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34590157/
generic parameters of trait function 的简单示例: trait Ext: Sized { fn then(self, f: fn(Self) -> R) -
在下面的代码中,为什么 Groovy 似乎忽略了方法 barMany 中提供的闭包参数的泛型类型声明: import groovy.transform.CompileStatic @CompileSt
据我所知,Prolog 没有任何内置机制用于generic programming。 .可以使用统一来模拟泛型,但这需要在运行时进行类型检查: :- initialization(main). :-
在我的应用程序中,我有一个 Board。董事会由细胞组成。每个单元格都有一个 int 值。有几种类型的 Board 可以扩展 Board。每种类型的板将以不同方式表示单元格。例如,一个人会使用 Lis
我想将存储的属性添加到 UIView 子类中,例如UIView、UIImageView、UIPickerView等, 我只需要从子类创建 UIView 的实例子类仅类型不同,所有属性和方法都相同。 T
这个问题在这里已经有了答案: Any type and implementing generic list in go programming language (2 个答案) 关闭 6 个月前。
我有以下代码as seen in ideone.com : import java.util.*; class Test{ interface Visitor{ public
在 Swift 中,我们可以对序列等通用项编写扩展: extension Sequence where Iterator.Element : ObservableType { } 这将保证扩展仅适用于
我知道这听起来很困惑,但这是我能解释的最好的了。 (您可以建议一个更好的标题)。我有 3 节课:- A public class A > { ... } B public class B {
我目前在大学攻读 CS,我刚刚开始学习数据结构和算法类(class)。我的教授非常喜欢(实际上是强制我们)使用 Ada。为了取得成功,我开始查找一些东西并找到了这段代码,它描述了如何编写通用堆栈: g
我正在玩 Scala By Example 开头的 QuickSort 示例并尝试将其调整为通用类型 A ,而不仅仅是 Int s。 到目前为止我的工作是 def sort[A new Y(i, -
谁能解释为什么下面的第二个例子不能编译? “测试 2”给出“错误 FS0670:此代码不够通用。类型变量 ^a 无法泛化,因为它会超出其范围。”。我无法理解此错误消息。 // Test 1 type
如何将泛型存储在非泛型对象持有的泛型TList中? type TXmlBuilder = class type TXmlAttribute= class Name: Str
我正在尝试通过遵循 wiki article 创建如何使用 GHC.Generics 的最小工作示例.这是我所拥有的: {-# LANGUAGE DefaultSignatures, DeriveGe
我正在尝试将 get 函数添加到 wiki 中描述的通用序列化中。 。有些部分看起来很简单,但有一些地方我非常不确定要写什么,毫不奇怪,我遇到了编译错误。我已经查看了原始论文以及 cereal 中的实
为什么这段代码有效? $v):void { print_r($v); } test(Vector {1, array("I'm an array"), 3}); 它不应该抛出错误吗?什么是应
有没有办法让 Rust Generic 只接受原始类型?我想稍后迭代值中的位,并且我知道这只有在原始类型中才有可能。 struct MyStruct { my_property: T // m
假设我有一个简单的类 public class MyObject { } 以及处理MyObject子类的handler接口(interface) public interface MyObjectHa
出于某种原因,我正在努力通过使用通用基类来实现通用接口(interface)的属性,如下所示: public interface IParent where TChild : IChild {
我收到以下错误。 google了一天多,还是找不到具体的解决方法,求大神指点,谢谢 ERROR: Cannot implicitly convert type System.Collections.G
我是一名优秀的程序员,十分优秀!