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.

Making output of one module the other one's clock

Status
Not open for further replies.

yttuncel

Junior Member level 3
Junior Member level 3
Joined
Nov 18, 2012
Messages
30
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Visit site
Activity points
1,663
Hello,

I am modifying a simple keyboard interface I found on the net. The idea is whenever there is a new scancode, it will make the output named "Scan_Dav" go high, and then go low. So when I direct Scan_Dav to another module as a clock, that module's clock will have a rising edge whenever a new ScanCode is pressed. Is there any error in my way of thinking? If there is none, I will put my codes and ask you why what I made is not working. Thanks
 

I wouldnt recommend doing that. Using logic generated clocks can cause all sorts of timing problems. it would be best to clock the sub module at the system clock and build a rising edge detector.
 

I tried it the other way around but it did not work. It was like this:


Code VHDL - [expand]
1
2
3
4
5
if rising_edge(clk) then
    if Scan_Dav = '1' then
    -- do the shifting here
    end if;
end if;



EDIT: Also, I want to wait till someone presses Enter to scroll the text. So until enter is pressed, the text is to shift by one digit only when a new scancode is arrived.
 
Last edited:

I tried it the other way around but it did not work. It was like this:

Code:
if rising_edge(clk) then
   Scan_Dav_Sync(0) <= Scan_Dav;
   Scan_Dav_Sync(1) <= Scan_Dav_Sync(0);
   Previous_Scan_Dav <= Scan_Dav_Sync(1);
   if (Previous_Scan_Dav = '0') and (Scan_Dav_Sync(1) = '1') then
      -- do the shifting here
   end if;
end if;

EDIT: Also, I want to wait till someone presses Enter to scroll the text. So until enter is pressed, the text is to shift by one digit only when a new scancode is arrived.

Above code has been edited with the following changes
- Scan_Dav_Sync added to synchrnoize the Scan_Dav input to the clock
- Previous_Scan_Dav added to store the previous state so that the 'rising edge' (i.e. used to be low, now it's high) of Scan_Dav can be detected

Kevin Jennings
 

I got the idea here, but what changes implementing like this will make? Also I need to use the board's clock with this one right? I will update here after I try what you suggested. Thank you KJ

UPDATE: I tried what is suggested. Below is the code


Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
signal bytes : std_logic_vector(63 downto 0);
signal Scan_Dav_Sync: std_logic_vector(1 downto 0):="00";
signal Previous_Scan_Dav: std_logic:='0';
begin
    process (clk) begin --clk is 50 MHz
        if rising_edge(clk) then
             Scan_Dav_Sync(0) <= Scan_Dav;
             Scan_Dav_Sync(1) <= Scan_Dav_Sync(0);
             Previous_Scan_Dav <= Scan_Dav_Sync(1);
             if (Previous_Scan_Dav = '0') and (Scan_Dav_Sync(1) = '1') then
                 bytes <= bytes (bytes'high-8 downto 0) & Data_in;
             end if;
          end if;
    end process;


I used 50 Mhz clock. Still this inserts 2 "Data_in"s, and shows 2 of each letter on seven segment display. Do you wish to have a look at where Scan_Dav comes from, maybe that is the source of the error?

EDIT: What could be the reason keyboard controller reads data 2 times? and thus changing scan_dav 2 times?
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top