EDAboard.com | EDAboard.de | EDAboard.co.uk | WTWH Media

elektroda.net NewsGroups Forum Index - VHDL Language - **Easy way to use LEDR to show the duplicate numbers?**

Guest

Thu Sep 28, 2017 5:43 am

I am working for a simple slot machine by using VHDL, the specifition

let me to show the duplicate numbers which is the result of the spin. It

could be many duplicates of the same number or different numbers have

appeared at least twice.

For example,

if the number is 278551 then there are two 5 to lit two LEDR

if the number is 578551 then there are three 5 to lit three LEDR

if the number is 278558 then there are two 5 and two 8 to lit four LEDR

if the number is 578558 then there are three 5 and two 8 to lit five

LEDR

if the number is 585885 then there are three 5 and three 8 to lit six

LEDR

if the number is 777777 then there are six 7 to lit six LEDR

So is there any simple way to implement this function? I was trying to

use FSM but it looks to complicated.

Needs some help

Guest

Thu Sep 28, 2017 8:51 am

yhc199494_at_gmail.com wrote on 9/27/2017 11:43 PM:

I am working for a simple slot machine by using VHDL, the specifition

let me to show the duplicate numbers which is the result of the spin. It

could be many duplicates of the same number or different numbers have

appeared at least twice.

For example,

if the number is 278551 then there are two 5 to lit two LEDR

if the number is 578551 then there are three 5 to lit three LEDR

if the number is 278558 then there are two 5 and two 8 to lit four LEDR

if the number is 578558 then there are three 5 and two 8 to lit five

LEDR

if the number is 585885 then there are three 5 and three 8 to lit six

LEDR

if the number is 777777 then there are six 7 to lit six LEDR

So is there any simple way to implement this function? I was trying to

use FSM but it looks to complicated.

Needs some help

let me to show the duplicate numbers which is the result of the spin. It

could be many duplicates of the same number or different numbers have

appeared at least twice.

For example,

if the number is 278551 then there are two 5 to lit two LEDR

if the number is 578551 then there are three 5 to lit three LEDR

if the number is 278558 then there are two 5 and two 8 to lit four LEDR

if the number is 578558 then there are three 5 and two 8 to lit five

LEDR

if the number is 585885 then there are three 5 and three 8 to lit six

LEDR

if the number is 777777 then there are six 7 to lit six LEDR

So is there any simple way to implement this function? I was trying to

use FSM but it looks to complicated.

Needs some help

This is a problem that is easier to solve in sequential code than

combinatorial code. There are a lot of possible combinations you need to

check for by comparing each digit against every other digit. Fortunately

any matches are considered the same if some are one digit and others are a

different digit. Soooo...

I would write two nested loops. Initialize a counter to zero. We'll call

the index i, it runs from 1 to 5. The inner loop runs from i+1 to 6.

Perform an equality test on each combination and if they match increment the

counter by 1. At the end of those two loops you will have a count that can

be used to select which light to turn on.

This will generate a lot of logic though. If you need to synthesize it,

make sure your counter is limited to a range of 0 to 6. That will help a

lot since the default is 32 bits. Same with the digits, limit them to a

range of 0 to 9. Unfortunately the compares will require 15 compares and 14

adders for the count.

Does that make sense? Do you know how to code with sequential code in VHDL?

--

Rick C

Viewed the eclipse at Wintercrest Farms,

on the centerline of totality since 1998

Guest

Fri Sep 29, 2017 9:50 pm

On 2017-09-28 01:51, rickman wrote:

yhc199494_at_gmail.com wrote on 9/27/2017 11:43 PM:

I am working for a simple slot machine by using VHDL, the specifition

let me to show the duplicate numbers which is the result of the spin. It

could be many duplicates of the same number or different numbers have

appeared at least twice.

For example,

if the number is 278551 then there are two 5 to lit two LEDR

if the number is 578551 then there are three 5 to lit three LEDR

if the number is 278558 then there are two 5 and two 8 to lit four LEDR

if the number is 578558 then there are three 5 and two 8 to lit five

LEDR

if the number is 585885 then there are three 5 and three 8 to lit six

LEDR

if the number is 777777 then there are six 7 to lit six LEDR

So is there any simple way to implement this function? I was trying to

use FSM but it looks to complicated.

Needs some help :)

This is a problem that is easier to solve in sequential code than

combinatorial code. There are a lot of possible combinations you need

to check for by comparing each digit against every other digit.

Fortunately any matches are considered the same if some are one digit

and others are a different digit. Soooo...

I would write two nested loops. Initialize a counter to zero. We'll

call the index i, it runs from 1 to 5. The inner loop runs from i+1 to

6. Perform an equality test on each combination and if they match

increment the counter by 1. At the end of those two loops you will have

a count that can be used to select which light to turn on.

This will generate a lot of logic though. If you need to synthesize it,

make sure your counter is limited to a range of 0 to 6. That will help

a lot since the default is 32 bits. Same with the digits, limit them to

a range of 0 to 9. Unfortunately the compares will require 15 compares

and 14 adders for the count.

Does that make sense? Do you know how to code with sequential code in

VHDL?

I am working for a simple slot machine by using VHDL, the specifition

let me to show the duplicate numbers which is the result of the spin. It

could be many duplicates of the same number or different numbers have

appeared at least twice.

For example,

if the number is 278551 then there are two 5 to lit two LEDR

if the number is 578551 then there are three 5 to lit three LEDR

if the number is 278558 then there are two 5 and two 8 to lit four LEDR

if the number is 578558 then there are three 5 and two 8 to lit five

LEDR

if the number is 585885 then there are three 5 and three 8 to lit six

LEDR

if the number is 777777 then there are six 7 to lit six LEDR

So is there any simple way to implement this function? I was trying to

use FSM but it looks to complicated.

Needs some help :)

This is a problem that is easier to solve in sequential code than

combinatorial code. There are a lot of possible combinations you need

to check for by comparing each digit against every other digit.

Fortunately any matches are considered the same if some are one digit

and others are a different digit. Soooo...

I would write two nested loops. Initialize a counter to zero. We'll

call the index i, it runs from 1 to 5. The inner loop runs from i+1 to

6. Perform an equality test on each combination and if they match

increment the counter by 1. At the end of those two loops you will have

a count that can be used to select which light to turn on.

This will generate a lot of logic though. If you need to synthesize it,

make sure your counter is limited to a range of 0 to 6. That will help

a lot since the default is 32 bits. Same with the digits, limit them to

a range of 0 to 9. Unfortunately the compares will require 15 compares

and 14 adders for the count.

Does that make sense? Do you know how to code with sequential code in

VHDL?

I would probably implement this with combinatorial logic.

Have an LED assigned to each digit position. For each digit you need 5

4-bit comparators to compare that digit with the other 5. OR all 5 of

the comparator outputs for that digit together. If the result is a '1',

turn on the LED for that digit position.

Charles Bailey

Guest

Fri Sep 29, 2017 11:23 pm

Charles Bailey wrote on 9/29/2017 3:50 PM:

On 2017-09-28 01:51, rickman wrote:

yhc199494_at_gmail.com wrote on 9/27/2017 11:43 PM:

I am working for a simple slot machine by using VHDL, the specifition

let me to show the duplicate numbers which is the result of the spin. It

could be many duplicates of the same number or different numbers have

appeared at least twice.

For example,

if the number is 278551 then there are two 5 to lit two LEDR

if the number is 578551 then there are three 5 to lit three LEDR

if the number is 278558 then there are two 5 and two 8 to lit four LEDR

if the number is 578558 then there are three 5 and two 8 to lit five

LEDR

if the number is 585885 then there are three 5 and three 8 to lit six

LEDR

if the number is 777777 then there are six 7 to lit six LEDR

So is there any simple way to implement this function? I was trying to

use FSM but it looks to complicated.

Needs some help :)

This is a problem that is easier to solve in sequential code than

combinatorial code. There are a lot of possible combinations you need

to check for by comparing each digit against every other digit.

Fortunately any matches are considered the same if some are one digit

and others are a different digit. Soooo...

I would write two nested loops. Initialize a counter to zero. We'll

call the index i, it runs from 1 to 5. The inner loop runs from i+1 to

6. Perform an equality test on each combination and if they match

increment the counter by 1. At the end of those two loops you will have

a count that can be used to select which light to turn on.

This will generate a lot of logic though. If you need to synthesize it,

make sure your counter is limited to a range of 0 to 6. That will help

a lot since the default is 32 bits. Same with the digits, limit them to

a range of 0 to 9. Unfortunately the compares will require 15 compares

and 14 adders for the count.

Does that make sense? Do you know how to code with sequential code in

VHDL?

I would probably implement this with combinatorial logic.

Have an LED assigned to each digit position. For each digit you need 5

4-bit comparators to compare that digit with the other 5. OR all 5 of the

comparator outputs for that digit together. If the result is a '1', turn on

the LED for that digit position.

yhc199494_at_gmail.com wrote on 9/27/2017 11:43 PM:

I am working for a simple slot machine by using VHDL, the specifition

let me to show the duplicate numbers which is the result of the spin. It

could be many duplicates of the same number or different numbers have

appeared at least twice.

For example,

if the number is 278551 then there are two 5 to lit two LEDR

if the number is 578551 then there are three 5 to lit three LEDR

if the number is 278558 then there are two 5 and two 8 to lit four LEDR

if the number is 578558 then there are three 5 and two 8 to lit five

LEDR

if the number is 585885 then there are three 5 and three 8 to lit six

LEDR

if the number is 777777 then there are six 7 to lit six LEDR

So is there any simple way to implement this function? I was trying to

use FSM but it looks to complicated.

Needs some help :)

This is a problem that is easier to solve in sequential code than

combinatorial code. There are a lot of possible combinations you need

to check for by comparing each digit against every other digit.

Fortunately any matches are considered the same if some are one digit

and others are a different digit. Soooo...

I would write two nested loops. Initialize a counter to zero. We'll

call the index i, it runs from 1 to 5. The inner loop runs from i+1 to

6. Perform an equality test on each combination and if they match

increment the counter by 1. At the end of those two loops you will have

a count that can be used to select which light to turn on.

This will generate a lot of logic though. If you need to synthesize it,

make sure your counter is limited to a range of 0 to 6. That will help

a lot since the default is 32 bits. Same with the digits, limit them to

a range of 0 to 9. Unfortunately the compares will require 15 compares

and 14 adders for the count.

Does that make sense? Do you know how to code with sequential code in

VHDL?

I would probably implement this with combinatorial logic.

Have an LED assigned to each digit position. For each digit you need 5

4-bit comparators to compare that digit with the other 5. OR all 5 of the

comparator outputs for that digit together. If the result is a '1', turn on

the LED for that digit position.

Yeah, I was not paying attention to how they wanted the LEDs to light. I

also didn't use the right terminology for the code. I should have said I

would use sequential code rather than concurrent code.

I would describe this in a loop with sequential code rather than to code the

many compares by hand in concurrent code. Sequential code does not

necessarily imply sequential logic, it can also be used for combinatorial

logic and combinatorial logic is the right way to go for most

implementations of this problem.

--

Rick C

Viewed the eclipse at Wintercrest Farms,

on the centerline of totality since 1998

Guest

Tue Oct 03, 2017 2:46 pm

On Thursday, 28 September 2017 16:52:02 UTC+10, rickman wrote:

I would write two nested loops. Initialize a counter to zero. We'll call

the index i, it runs from 1 to 5. The inner loop runs from i+1 to 6.

Perform an equality test on each combination and if they match increment the

counter by 1. At the end of those two loops you will have a count that can

be used to select which light to turn on.

This will generate a lot of logic though. If you need to synthesize it,

make sure your counter is limited to a range of 0 to 6. That will help a

lot since the default is 32 bits. Same with the digits, limit them to a

range of 0 to 9. Unfortunately the compares will require 15 compares and 14

adders for the count.

Does that make sense? Do you know how to code with sequential code in VHDL?

--

Rick C

Viewed the eclipse at Wintercrest Farms,

on the centerline of totality since 1998

Im not very sure about your method, could you write some like sample VHDL code for me to understand?

James D

Guest

Tue Oct 03, 2017 9:56 pm

yhc199494_at_gmail.com wrote on 10/3/2017 8:46 AM:

On Thursday, 28 September 2017 16:52:02 UTC+10, rickman wrote:

I would write two nested loops. Initialize a counter to zero. We'll call

the index i, it runs from 1 to 5. The inner loop runs from i+1 to 6.

Perform an equality test on each combination and if they match increment the

counter by 1. At the end of those two loops you will have a count that can

be used to select which light to turn on.

This will generate a lot of logic though. If you need to synthesize it,

make sure your counter is limited to a range of 0 to 6. That will help a

lot since the default is 32 bits. Same with the digits, limit them to a

range of 0 to 9. Unfortunately the compares will require 15 compares and 14

adders for the count.

Does that make sense? Do you know how to code with sequential code in VHDL?

Im not very sure about your method, could you write some like sample VHDL code for me to understand?

I would write two nested loops. Initialize a counter to zero. We'll call

the index i, it runs from 1 to 5. The inner loop runs from i+1 to 6.

Perform an equality test on each combination and if they match increment the

counter by 1. At the end of those two loops you will have a count that can

be used to select which light to turn on.

This will generate a lot of logic though. If you need to synthesize it,

make sure your counter is limited to a range of 0 to 6. That will help a

lot since the default is 32 bits. Same with the digits, limit them to a

range of 0 to 9. Unfortunately the compares will require 15 compares and 14

adders for the count.

Does that make sense? Do you know how to code with sequential code in VHDL?

Im not very sure about your method, could you write some like sample VHDL code for me to understand?

Sequential code can be in a process or in a procedure. Here is a process

for you. It has been a while since I wrote VHDL and I don't want to bother

with syntax details, plus I specifically included a couple of errors for you

to find and fix. So use this as a suggestion only.

type Slot_Digit_type is array (0 to 5) of integer range 0 to 9;

type LED_bank_type is unsigned (SlotDigits'high downto SlotDigits'low);

signal LEDBank : LED_bank_type;

signal SlotDigits : Slot_Digit_type;

process (clk, rst)

begin

if (rst) then

LEDBank <= (others -> '0');

elsif (rising_edge(clk)) then

for I in SlotDigits'low to SlotDigits'high loop

for J in SlotDigits'low to SlotDigits'high loop

if (I = J) then

if (SlotDigits(I) <> SlotDigits(J)) then

LEDBank(I) <= '1';

end if;

end if;

end for;

end for;

end if;

end process;

The logic this will generate will be 6 rows of 5 comparators. The outputs

of each row of compares are ORed together to control one LED. This is not

as efficient as it could be. This is using twice as many compares as

needed. How can you change the algorithm to cut the number of compares in

half?

--

Rick C

Viewed the eclipse at Wintercrest Farms,

on the centerline of totality since 1998

elektroda.net NewsGroups Forum Index - VHDL Language - **Easy way to use LEDR to show the duplicate numbers?**