Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Help with multiplexed display

Status
Not open for further replies.

madalin1990

Full Member level 2
Joined
Apr 4, 2012
Messages
124
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Activity points
2,090
I am trying to decribe a verilog module for a multiplexed display,but i just keep doing it wrong.Here is what i have tried.If someone could tell me where is my mistake i would be grateful.


Code Verilog - [expand]
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
76
module selector(
clk,
rst,
an_sel,
data0,
data1,
data2,
data3,
data4,
data_out
);
 
input clk,rst;
output reg [4:0] an_sel;
output reg [2:0] data_out;
input [7:0] data0,data1,data2,data3,data4;
 
reg q;
always @(posedge clk,posedge rst)
begin:COUNTER
if(rst == 1'b1)begin
    q <=3'b0;
    end  else
    if(q==3'b100)begin
    q<= 3'b0;
    end
     else begin
     q<=q+1;
     end
end
 
reg sel;
always @(q)
begin
if(q==3'b0)begin
an_sel <=5'b00001;// 5'b10000;
sel<=3'b0;
end else 
 
if(q==3'b001)begin
an_sel <= 5'b00010;//5'b01000;
sel<=3'b001;
end else
 
 if(q==3'b010)begin
an_sel <=5'b00100;// 5'b00100;
sel<=3'b010;
 
end else
if(q==3'b011)begin
an_sel <=5'b01000;//5'b00010;
sel<=3'b011;
end else 
 
begin
an_sel <=5'b10000;// 5'b00001;
sel<=3'b100;
end
 
 
end 
 
 
 
always @(sel)
begin
case(sel)
  0:data_out = data0;
  1:data_out = data1;
  2:data_out = data2;
  3:data_out = data3;
  4:data_out = data4;
  default : data_out=~8'b00111111;
  endcase
  end
endmodule

 
Last edited by a moderator:

First of all, what is the problem you are facing with this logic?.
 
  • Like
Reactions: zhpyu

    zhpyu

    Points: 2
    Helpful Answer Positive Rating
madalin1990,

I never used Verilog language, in fact I've just ended up reading basic syntax for this post...

One thing I know... It is not normal to do that many operations between different sizes variables...

for example:

reg q; is one bit variable

you are assigning to it a 3 bit value and doing logic equality operations with 3 bits values...

Code:
reg q;
always @(posedge clk,posedge rst)
begin:COUNTER
if(rst == 1'b1)begin
    q <=3'b0;

You should declare it with 3bit size...


same thing appening with reg sel;

Code:
reg sel;
always @(q)
begin
if(q==3'b0)begin
an_sel <=5'b00001;// 5'b10000;
sel<=3'b0;

reg sel should also be 3bit size

finally your data_out register is 3 bit wide, and you are assigning to it a 8bit wide variable:

Code:
  0:data_out = data0;
  1:data_out = data1;
  2:data_out = data2;
  3:data_out = data3;
  4:data_out = data4;
  default : data_out=~8'b00111111;

data_out should also be 8 bit wide by this logic... makes sense 7 segments plus a dot segment

once again I never used this language.. I can only guess what You mean with the code...

anyway I suggest:



Code Verilog - [expand]
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
76
module selector(
clk,
rst,
an_sel,
data0,
data1,
data2,
data3,
data4,
data_out
);
 
input clk,rst;
output reg [4:0] an_sel;
output reg [7:0] data_out;
input [7:0] data0,data1,data2,data3,data4;
 
reg [2:0] q;
always @(posedge clk,posedge rst)
begin:COUNTER
if(rst == 1'b1)begin
    q <=3'b0;
    end  else
    if(q==3'b100)begin
    q<= 3'b0;
    end
     else begin
     q<=q+1;
     end
end
 
reg [2:0] sel;
always @(q)
begin
if(q==3'b0)begin
an_sel <=5'b00001;// 5'b10000;
sel<=3'b0;
end else 
 
if(q==3'b001)begin
an_sel <= 5'b00010;//5'b01000;
sel<=3'b001;
end else
 
 if(q==3'b010)begin
an_sel <=5'b00100;// 5'b00100;
sel<=3'b010;
 
end else
if(q==3'b011)begin
an_sel <=5'b01000;//5'b00010;
sel<=3'b011;
end else 
 
begin
an_sel <=5'b10000;// 5'b00001;
sel<=3'b100;
end
 
 
end 
 
 
 
always @(sel)
begin
case(sel)
  0:data_out = data0;
  1:data_out = data1;
  2:data_out = data2;
  3:data_out = data3;
  4:data_out = data4;
  default : data_out=~8'b00111111;
  endcase
  end
endmodule

 
Last edited:
It worked after making those changes.
Thank you!
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top