| |
1. setup time 和 hold time 不满足情况下应该如何解决? 2. 什么叫做亚稳态,如何解决? 3. Verilog中 => 和 = 有什么区别? 4. 画一个D触发器的原理图(门级),并且用verilog gate level表示出来; 5. 用最少的Mos管画出一个与非门; 6. 写一段finite state machine(主要考察coding style);如果触发器的setup time/hold time不满足,这个数据就不能被这一时钟打入触发器,只有在下一个时钟上升沿到来时,数据才能被打入触发器。 在同步系统中,如果触发器的setup time/hold time不满足,就可能产生亚稳态(Metastability),导致采样错误。此时触发器输出端Q在有效时钟沿之后比较长的一段时间处于不确定的状态,在这段时间里Q端毛刺、振荡、固定的某一电压值,而不是等于数据输入端D的值。这段之间成为决断时间(resolution time)。经过resolution time之后Q端将稳定到0或1上,但是究竟是0还是1,这是随机的,与输入没有必然的关系。 只要系统中有异步元件,亚稳态就是无法避免的,因此设计的电路首先要减少亚稳态导致错误的发生,其次要使系统对产生的错误不敏感。前者需要同步来实现,而后者根据不同的设计应用有不同的处理办法 题目是都用英文写的,我用汉字来表达 1, a为输入端,b为输出端,如果a连续输入为1101则b输出为1,否则为0 例如a:0001100110110100100110 b:0000000000100100000000 请画出state machine 2, 请用RTL描述上题state machine 3,library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity check1101 is Port ( a : in std_logic; clk : in std_logic; b : out std_logic); end check1101; architecture Behavioral of check1101 is signal p : std_logic_vector(0 to 3); begin serial2parallel: process(clk) begin if clk'event and clk='1' then p<=a&p(0 to 2); end if; end process; check: process(clk,p) begin if clk'event and clk='1' then if p = "1101" then b<= '1'; else b<= '0'; end if; end if; end process; end Behavioral; 我的一个同事说的。 你的p其实就是一个状态,应该是设两个状态就足够了:1101和OTHERS 这只是一个典型的设计题目,而且用状态机做并没有使设计复杂化 你下面的设计会实现有两个延时,不过我相信出题的人不会在意这个的。 还有就是,状态机设计一般都有reset的,你要加上这个端口才比较好,当然不加也不算不完整吧 此题scholes描述的,只有一个延时。修改如下: library ieee; use ieee.std_logic_1164.all; use ieee.STD_LOGIC_ARITH.all; use ieee.STD_LOGIC_UNSIGNED.all; entity test is port ( rst : in std_logic; clk : in std_logic; a : in std_logic; b : out std_logic ); end test; architecture test of test is signal p: std_logic_vector(3 downto 0 ); begin Start:process (rst, clk, p, a) begin -- process if rst = '1' then if clk'event and clk = '1' then p<=p(2 downto 0)&a; end if; else p<="0000"; end if; end process; Start1:process (rst, clk, p) begin -- process if rst = '1' then if clk'event and clk = '1' then if p = "1101" then b<='1'; else b<='0'; end if; end if; else b<='0'; end if; end process; end test; 本题考察利用有限状态机进行时序逻辑的设计 下面用verilog进行描述:(有限状态机提供6个状态) module sequence_detect(in,out,clk,rst,state); output out; output[2:0]state; input clk; input rst; input in; reg[2:0]state; wire out; parameter IDLE='d0, A='d1, B='d2, C='d3, D='d4, E='d5; assign ut=((state==D)&&(in==1))?1:0; always @(posedge clk) begin if(!rst) begin state<=IDLE; end else case(state) IDLE:if(in==1) // the first code is right, storing the state A // begin state<=A; end A:if(in==1) // the second code is right, storing the state B // begin state<=B; end else begin state<=IDLE; end B:if(in==0) // the third code is right, storing the state C // begin state<=C; end else begin state<=E; end C:if(in==1) // the fourth code is right, storing the state D // begin state<=D; // out<=1; end else begin state<=IDLE; // out<=0; end D:if(in==1) // connecting the front inputted sequence,again introducing one,storing state B // begin state<=B; end else begin state<=IDLE; end E:if(in==0) begin state<=C; end else begin state<=B; end default:state=IDLE; endcase end endmodule library ieee; use ieee.std_logic_1164.all; use ieee.STD_LOGIC_ARITH.all; use ieee.STD_LOGIC_UNSIGNED.all; entity test is port ( rst : in std_logic; clk : in std_logic; a : in std_logic; b : out std_logic ); end test; architecture test of test is signal p: std_logic_vector(2 downto 0 ); begin Start:process (rst, clk) begin if rst = '1' then p<="000"; if clk'event and clk = '1' then p<=p(1 downto 0)&a; end if; end if; end process; Start1:process (rst, clk) begin -- process if rst = '1' then b<='0'; if clk'event and clk = '1' then if p = "110" and a='1' then b<='1'; else b<='0'; end if; end if; end if; end process; end test; 有两段代码 1。proceee(a,b,c,sel,y) begin if (sel) y = a+b; else y = a+c; end 2.y = sel ? a+b : a+c; 面试官说第一中表达方法是先选后加,所以电路实现是一个选择器和一个加法器 第二种方法是先加后选,用到两个加法器和一个选择器,所以他说第一种表达方式要好一些。 查了一下书,发现面试官说的并不全对,一般来说,综合工具会自动的优化,一般只会综合出一个加法器和一个选择器 先选后加是加法器共用,节省面积 先加后选是用面积换时间,电路的工作速度更快些。为了实现逻辑(A XOR B)OR (C AND D),请选用以下逻辑中的一种,并说明为什么? 1)INV 2)AND 3)OR 4)NAND 5)NOR 6)XOR 我没有做出来,请大家帮忙看看 我想了一下,用与非是肯定可以实现的 1。与非门的两个输入连在一起就成了非门 2。或门可以用与非和非门搭建 或非其实也可以 1。或非的两个输入PAD连在一起成非门 2。与门可以用或非门和非门搭建 奇数分频(6或者3) module s1 (// {{ALTERA_ARGS_BEGIN}} DO NOT REMOVE THIS LINE! clkin, clkout, s1, s2 // {{ALTERA_ARGS_END}} DO NOT REMOVE THIS LINE! );// Port Declaration // {{ALTERA_IO_BEGIN}} DO NOT REMOVE THIS LINE! input clkin; output clkout, s1, s2; // {{ALTERA_IO_END}} DO NOT REMOVE THIS LINE! wire s1,s2; reg [1:0] step1, step2; always @(posedge clkin) begin case (step1) 2'b00: step1<=2'b01; 2'b01: step1<=2'b10; 2'b10: step1<=2'b00; default :step1<=2'b00; endcase end always @(negedge clkin) begin case (step2) 2'b00: step2<=2'b01; 2'b01: step2<=2'b10; 2'b10: step2<=2'b00; default :step2<=2'b00; endcase end assign clkout=step1[1]|step2[1]; assign s1=step1[1]; assign s2=step2[1]; endmodule testbench: `timescale 1ns/1ns module s1_tb; reg clk_in; wire clk_out,s1, s2; always #50 clk_in=~clk_in; initial begin clk_in=0; #1000 $stop; end s1 s10(.clkin(clk_in), .clkout(clk_out), .s1(s1), .s2(s2)); endmodule 独立晶振 一个10m一个15m ,10m向15m的传输数据问怎么实现 我说小数分频成10m内部时钟,再采样 求正解 数据量少用握手信号,数据量多用FIFO,如果有很高的时钟资源可以考虑用高时钟采样,但是不是很好的方法,分频成5M是肯定不行的,分成相同频率也是异步信号 |