Memory Elements
:material-circle-edit-outline: 约 408 个字 :fontawesome-solid-code: 27 行代码 :material-image-multiple-outline: 8 张图片 :material-clock-time-two-outline: 预计阅读时间 4 分钟
Flip-Flops and Latches¶
- Latch: A memory element in which the output is equal to the value of the stored state inside the element and the state is changed whenever the appropriate inputs change and the clock is asserted.
- Flip-Flop: A memory element for which the output is equal to the value of the stored state inside the element and for which the internal state is changed only on a clock edge.
- Setup Time:
Because the D input is sampled on the clock edge, it must be valid for a period of time immediately before and immediately after the clock edge. The minimum time that the input must be valid before the clock edge is called the setup time.
Setup Time
Register Files¶
- Register File: A register file consists of a set of registers that can be read and written by supplying a register number to be accessed. A register file can be implemented with a decoder for each read or write port and an array of registers built from D flip-flops.
Register File
Register File with Read Ports
Register File with Write Ports
What happens if the same register is read and written in the same cycle?
Specifying Sequential Logic in Verilog¶
- Specifying a clock:
A clock is not a predefined object in Verilog; instead, we generate a clock by using the Verilog notation #n before a statement; this causes a delay of n simulation time steps before the execution of the statement. In most Verilog simulators, it is also possible to generate a clock as an external input, allowing the user to specify at simulation time the number of clock cycles during which to run a simulation.
- Specify the operation of an edge-triggered register:
In Verilog, this is done by using the sensitivity list on an always block and specifying as a trigger either the positive or negative edge of a binary variable with the notation posedge or negedge, respectively