- Verilog is a hardware description language.
- Hardware Description Language is used to describle digital hardware at any level(from flip-flop to a network switch).
// A simple D flip-flop
module d_ff(d, clk, q, q_bar);
input d, clk
output q, q_bar
wire d, clk
reg q, q_bar
always @ (posedge clk)
begin
q <= d;
q_bar <= !d;
end
endmodule
- Verilog allows one to design hardware at different levels of abstraction.
- Behavoiral Level
- Register Transfer Language(RTL)
- Gate level
- Switch level
- Traditional Method.
- Gate-level Design.
- Not scalable.
- Functional method.
- Perfered by most engineers.
- It also allows testing, easy change of different technologies, a structured system design.
- But not practical, so most of the design is hybrid of the the two.
- Design is expressed by concurrent algorithms.
- Each algorithm is sequential
- Functions, tasks and blocks are the main elements
- No regard to structural relization of the design
- Specify circuits by operation and transfer of data between registers
- clock used
- Any code that is synthesizable is called RTL code
- Logical links between components and timing characteristics
- Signals are discrete
- They take only one of the following level (1, 0, X, Z)
- They are programmed using gates
- It is not a scalable method so mostly it is generated by synthesis tools
- Before verilog chip design was done using schematics.
- They are harder to verify and error-prone with long tedious developement cycles
- Specification
- High Level design
- Low level(micro) design
- RTL coding
- Verification
- Synthesis
Arbiter: A device that selects among two agents competing for mastership.
- Specification
- Two agent arbiter.
- Active high asynchronous reset.
- Fixed Priority, with agen 0 having priority over agent 1.
- Grant will be asserted as long as request is asserted.
- High Level Design
- Low Level Design
- RTL coding
- It is automatically generated via verilog.
module arbiter(
clock,
reset,
req_0,
req_1,
gnt_0,
gnt_1
);
input clock;
input reset;
input req_0;
input req_1;
output gnt_0;
output gnt_1;
- input
- output
- inout
- set of signal
inout [7:0] address
represens an 8 bit bidirectional port
- driver is a data type that drives the load to the circuit
- It can store data(flip-flop) - reg
- It can connect end-points(wire) - wire
- "{}" braces are replace by begin and end
- if-else statement
if(enable == 1'b1) begin
data = 10;
address = 16'hDEAD;
wr_enable = 1'b1;
end else begin
data = 32'b0;
wr_enable = 1'b0;
address = address + 1;
end
- case statement
case(address)
0: $display ("case 1");
1: $display ("case 2");
default: $display ("case 3");
endcase
- while statement
while (free_time) begin
$display("While loop");
end
- for loop
for(i = 0; i < 16; i = i + 1) begin
$display("for loop %d", i);
end
- Repeat
repeat (16) begin
$display("repeat loop %d", i);
end