06 - Verilog - Labs - Homework
06 - Verilog - Labs - Homework
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
• In order to do a syntax check on the Verilog code written, vlogan tool can be used. The
following line can be executed on the shell
• Write the Verilog code that implements a 4-input multiplexer (mux) with variable (parameterized)
input and output bus width.
1 module mux4 #(
2 parameter WIDTH= 8 din1
3 ) ( din2
dout
4 input [WIDTH-1:0] din1, din2, din3, din4, din3
5 input [1:0] select, din4
6 output [WIDTH-1:0] dout
7 );
select
• Write the Verilog code that implements a D-type Register Bank with parameterized depth. It
should:
– Operate on positive edge of the clock (clk)
– Have a Synchronous reset (rst)
– Have an enable signal (wr_en) which allows data capturing only when asserted.
wr_en rst
© 2016 Synopsys, Inc. 6
Lab 2c – Basic ALU
• Write the Verilog code for a basic ALU module (Arithmetic Logic Unit).
– This ALU has to have addition, subtraction, multiplication and division operations.
– It should have two variable (parameterized) width inputs and output bus in accordance.
– Signal zero[0] should be asserted when the result of the current operation is 0.
– Signal error[0] should be asserted when dividing by 0 is attempted or when input data is not valid.
– On error condition, output must be forced to be -1
– Operations should be described using Verilog arithmetic operators.
zero
d_in1 2
d_in2 error
Mux A
d_in3 w
alu
{dout_high, dout_low}
2w
Mux B
2w 4
reset
clk
cmdin
control
6
• The control block shall be designed to implement the following Instruction Set Architecture
(ISA): cmdin
5 4 3 2 1 0