-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmulti_drop.v
More file actions
75 lines (73 loc) · 1.93 KB
/
multi_drop.v
File metadata and controls
75 lines (73 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer: Utkarsha
//
// Create Date: 16.12.2023 22:28:17
// Design Name: multi_drop.v
// Module Name: multi_drop
// Project Name: Multi drop bus
//
// Description:
// This Verilog project implements a Multi Drop Bus system where a shared 8-bit data bus can drive data into one of three registers (qa, qb, or qc) based on 3 enable signals.
// The multi_drop module captures data from the bus into the selected register on the rising edge of the clock, with support for asynchronous reset.
// Only one register is enabled at a time using a 3-bit select (ena, enb, enc).
// The testbench (multi_drop_tb) simulates various enable combinations, data values, and reset behavior to validate correct functionality.
// This design demonstrates how multiple modules can share a bus interface with controlled access—useful in memory-mapped systems and processor interfaces.
//
// Revision 0.01 - File Created
//
//////////////////////////////////////////////////////////////////////////////////
module multi_drop(qa, qb, qc, bus, ena, enb, enc, clk, rst);
output reg [7:0]qa, qb, qc;
input [7:0] bus;
input ena, enb, enc, clk;
input rst;
always@(posedge clk or posedge rst)
begin
if (rst) begin
qa <= 8'd0;
qb <= 8'd0;
qc <= 8'd0;
end
else
case ({ena, enb, enc})
3'b100: qa<=bus;
3'b010: qb<=bus;
3'b001: qc<=bus;
default: {qa, qb, qc}<=3'b000;
endcase
end
endmodule
module multi_drop_tb;
wire [7:0]qa, qb, qc;
reg [7:0] bus;
reg ena, enb, enc, clk;
reg rst;
multi_drop uv2(qa, qb, qc, bus, ena, enb, enc, clk, rst);
initial
begin
clk = 0;
forever #20 clk = ~clk;
end
initial
begin
rst = 1'b0;
bus = 8'b00110110;
{ena, enb, enc} = 3'b100;
#40;
rst = 1'b0;
bus = 8'b01001111;
{ena, enb, enc} = 3'b010;
#40;
rst = 1'b0;
bus = 8'b11110110;
{ena, enb, enc} = 3'b001;
#40;
rst = 1'b1;
bus = 8'b00110110;
{ena, enb, enc} = 3'b010;
#40;
$finish;
end
endmodule