Documente Academic
Documente Profesional
Documente Cultură
Gray
code number and vice-versa. Verify the Verilog code in Modelsim simulator by writing a test bench.
While designing architecture for binary code to gray code, use following parameters. A similar approach
has to
be used to carry out the conversion of gray code to binary code. Valid assumptions, if made, need to be
specified
clearly.
Parameters:
1. Define two 8 bit PIPO (Parallel In Parallel Out) registers (R1 and R2); R1 (for storing the binary
number),
R2 (for storing the gray coded number), and two one bit registers (R3, R4) for holding 1 bit values to be
xored.
● When R1_in is high, register can take data from the external bus.
● When R1_out is high, register can send data to the external bus.
3. The interconnect structure should be implemented using tri sate buffers and MUXs so as to avoid bus
contention.
● It will have three inputs: Start, Convert and Clock. The Convert signal, if ‘0’ controls binary to
● Output: R1_in, R1_out, R2_in, R2_out, R3_in, R3_out, R4_in, R4_out, and Done.
● When Start is high, process will start, else R2 register will hold 8 ’bzzzzzzzz value
● Done will go high when conversion is done and gray coded number is stored in R2, else will
remain in low.
● Use only Moore based FSM style for designing this control unit.
Verilog Code
/*module control_unit
(start,clock,convert,R1_in,R1_out,R2_in,R2_out,R3_in,R3_out,R4_in,R4_out,reset,done);
input start;
input clock;
input reset;
input convert;
output R1_in;
output R1_out;
output R2_in;
output R2_out;
output R3_in;
output R3_out;
output R4_in;
output R4_out;
output done;
reg R1_in;
reg R1_out;
reg R2_in;
reg R2_out;
reg R3_in;
reg R3_out;
reg R4_in;
reg R4_out;
reg done;
reg counter_load,counter_decrement;
if (!reset)
present_state <=5'd0;
else
end
case (present_state)
//end
// else begin
//end
end
5'd2: begin
end
5'd3: begin
end
5'd4: begin
end
5'd5: begin
end
5'd6: begin
end
5'd7: begin
end
5'd8: begin
end
5'd9: begin
end
5'd10: begin
end
5'd11: begin
end
5'd12: begin
end
5'd13: begin
end
5'd14: begin
end
5'd15: begin
end
5'd16: begin
end
5'd17: begin
end
5'd18: begin
end
default : begin
end
endcase
end
begin
if (!reset)
else if (counter_load)
else if (counter_decrement)
end
endmodule
input interconnect_data;
input clock,reset,R3_out;
output xor_out;
reg xor_out;
reg xor_in0,R3_out_d1;
if (!reset)
else
end
// Since interconnect can only hold current data, we need to hold the last data also for xoring
if (!reset) begin
end
else if (R3_out_d1)
end
if (!reset)
else
end
endmodule
module interconnect_module
(R1_out,R2_out,R3_out,R4_out,xor_out,R1_data,R2_data,R3_data,R4_data,interconnect_data, clock,
reset);
output interconnect_data;
reg interconnect_data;
//Control unit ensure that at a time only one of this will be 1 so its gray coded encoding
else begin
case({R1_out,R3_out,R4_out})
end
end
endmodule
module register_file
(interconnect_data,done,R1_in,R2_in,R3_in,R4_in,R1_data,R2_data,R3_data,R4_data,clock,reset,R1_o
ut,R2_out,R3_out,R4_out,external_bus);
reg R3,R4;
//Register R3 & R4
begin
if (!reset)
begin
R3 <= 1'b0;
R4 <= 1'b0;
end
R3 <= interconnect_data;
R4 <= R4;
end
R4 <= interconnect_data;
R3 <= R3;
end
end
//REG R1
begin
if (!reset)
R1 <= 8'd0;
else if (R1_in)
R1 <= external_bus;
end
begin
if (!reset)
else if (R1_out)
end
//REG R2
begin
if (!reset)
R2 <= 8'bzzzzzzzz;
else if (R2_in)
case (R2_write_pointer)
endcase
end
begin
if (!reset)
else if (R2_in)
end
endmodule
input clock,reset,start,convert;
output done;
wire
R1_in,R2_in,R3_in,R4_in,R1_out,R2_out,R3_out,R4_out,interconnect_data,R1_data,R2_data,R3_data,R
4_data;
xor_module u_xor(.*);
endmodule
*/
TB:
reg clock;
reg reset;
reg start, convert;
top my_top(.*);
initial
begin
clock = 1'b0;
end
initial begin
$dumpfile("dump.vcd");
$dumpvars;
reset = 1'b1;
end
initial begin
#20 convert = 0;
start = 1;
end
always @(*)
endmodule
Log File details:
[2020-04-04 14:01:31 EDT] irun -Q -unbuffered '-timescale' '1ns/1ns' '-sysv' '-access'
'+rw' design.sv testbench.sv
irun: 15.20-s038: (c) Copyright 1995-2017 Cadence Design Systems, Inc.
reg clock;
|
ncvlog: *W,ILLPDX (testbench.sv,5|10): Multiple declarations for a port not allowed in
module with ANSI list of port declarations (port 'clock') [12.3.4(IEEE-2001)].
reg reset;
|
ncvlog: *W,ILLPDX (testbench.sv,6|10): Multiple declarations for a port not allowed in
module with ANSI list of port declarations (port 'reset') [12.3.4(IEEE-2001)].
reg start, convert;
|
ncvlog: *W,ILLPDX (testbench.sv,7|10): Multiple declarations for a port not allowed in
module with ANSI list of port declarations (port 'start') [12.3.4(IEEE-2001)].
reg start, convert;
|
ncvlog: *W,ILLPDX (testbench.sv,7|19): Multiple declarations for a port not allowed in
module with ANSI list of port declarations (port 'convert') [12.3.4(IEEE-2001)].
reg [7:0] external_bus = 8'd2;
|
ncvlog: *W,ILLPDX (testbench.sv,9|23): Multiple declarations for a port not allowed in
module with ANSI list of port declarations (port 'external_bus') [12.3.4(IEEE-2001)].
Top level design units:
tb
ncelab: *W,DSEMEL: This SystemVerilog design will be simulated as per IEEE 1800-2009
SystemVerilog simulation semantics. Use -disable_sem2009 option for turning off SV
2009 simulation semantics.
xor_module u_xor(.*);
|
ncelab: *W,CUVDSO (./design.sv,290|21): 1 output port was not connected by dot-star:
ncelab: (./design.sv,164): xor_out