Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > CSDb Discussions > EF3 boot/reset VHDL
2020-05-25 11:07
oziphantom

Registered: Oct 2014
Posts: 478
EF3 boot/reset VHDL

I'm playing around with the EF3, but I can't get it to boot in a simulation.

I set the expansion port reset line to 'H' or 'Z' but the EF3 cart still holds it '0' or 'U' depending if I have it in Behavioral simulation or Post-Fit. There are also a lot of 'X' signals.

Does anybody know how it is suppose to boot?
2020-05-25 16:09
tlr

Registered: Sep 2003
Posts: 1714
Maybe you should provide a bit more info on what you are running exactly, and what code base?

Found this: https://bitbucket.org/skoe/easyflash/src/master/Hardware/ef3-vh.. Is that it?
2020-05-25 16:15
oziphantom

Registered: Oct 2014
Posts: 478
That is it.
2020-05-25 16:16
tlr

Registered: Sep 2003
Posts: 1714
So what testbench are you running and using which toolset?
2020-05-25 16:53
oziphantom

Registered: Oct 2014
Posts: 478
Xillnix ISE iSim.

LIBRARY ieee;
USE ieee.std_logic_1164.ALL;

ENTITY EF64TestBench IS
END EF64TestBench;
 
ARCHITECTURE behavior OF EF64TestBench IS 
 
    -- Component Declaration for the Unit Under Test (UUT)
 
    COMPONENT ef3
    PORT(
         addr : INOUT  std_logic_vector(15 downto 0);
         data : INOUT  std_logic_vector(7 downto 0);
         n_dma : OUT  std_logic;
         ba : IN  std_logic;
         n_roml : IN  std_logic;
         n_romh : IN  std_logic;
         n_io1 : IN  std_logic;
         n_io2 : IN  std_logic;
         n_wr : IN  std_logic;
         n_irq : INOUT  std_logic;
         n_nmi : INOUT  std_logic;
         n_reset_io : INOUT  std_logic;
         clk : IN  std_logic;
         phi2 : IN  std_logic;
         n_exrom : INOUT  std_logic;
         n_game : INOUT  std_logic;
         button_a : IN  std_logic;
         button_b : IN  std_logic;
         button_c : IN  std_logic;
         n_led : OUT  std_logic;
         mem_addr : OUT  std_logic_vector(22 downto 0);
         mem_data : INOUT  std_logic_vector(7 downto 0);
         n_mem_wr : OUT  std_logic;
         n_mem_oe : OUT  std_logic;
         n_flash_cs : OUT  std_logic;
         n_ram_cs : OUT  std_logic;
         n_usb_txe : IN  std_logic;
         n_usb_rxf : IN  std_logic;
         usb_wr : OUT  std_logic;
         n_usb_rd : OUT  std_logic
        );
    END COMPONENT;
    

   --Inputs
   signal ba : std_logic := '0';
   signal n_roml : std_logic := '0';
   signal n_romh : std_logic := '0';
   signal n_io1 : std_logic := '0';
   signal n_io2 : std_logic := '0';
   signal n_wr : std_logic := '0';
   signal clk : std_logic := '0';
   signal phi2 : std_logic := '0';
   signal button_a : std_logic := '0';
   signal button_b : std_logic := '0';
   signal button_c : std_logic := '0';
   signal n_usb_txe : std_logic := '0';
   signal n_usb_rxf : std_logic := '0';

	--BiDirs
   signal addr : std_logic_vector(15 downto 0);
   signal data : std_logic_vector(7 downto 0);
   signal n_irq : std_logic;
   signal n_nmi : std_logic;
   signal n_reset_io : std_logic;
   signal n_exrom : std_logic;
   signal n_game : std_logic;
   signal mem_data : std_logic_vector(7 downto 0);

 	--Outputs
   signal n_dma : std_logic;
   signal n_led : std_logic;
   signal mem_addr : std_logic_vector(22 downto 0);
   signal n_mem_wr : std_logic;
   signal n_mem_oe : std_logic;
   signal n_flash_cs : std_logic;
   signal n_ram_cs : std_logic;
   signal usb_wr : std_logic;
   signal n_usb_rd : std_logic;

   signal c128_reset_mirror : std_logic;

   -- Clock period definitions
   constant clk_period : time := 40 ns; -- ef3 has a 25mhz clock
   constant C128_clk_period : time := 500ns; -- 1mhz mode
 
BEGIN
 
	-- Instantiate the Unit Under Test (UUT)
   uut: ef3 PORT MAP (
          addr => addr,
          data => data,
          n_dma => n_dma,
          ba => ba,
          n_roml => n_roml,
          n_romh => n_romh,
          n_io1 => n_io1,
          n_io2 => n_io2,
          n_wr => n_wr,
          n_irq => n_irq,
          n_nmi => n_nmi,
          n_reset_io => n_reset_io,
          clk => clk,
          phi2 => phi2,
          n_exrom => n_exrom,
          n_game => n_game,
          button_a => button_a,
          button_b => button_b,
          button_c => button_c,
          n_led => n_led,
          mem_addr => mem_addr,
          mem_data => mem_data,
          n_mem_wr => n_mem_wr,
          n_mem_oe => n_mem_oe,
          n_flash_cs => n_flash_cs,
          n_ram_cs => n_ram_cs,
          n_usb_txe => n_usb_txe,
          n_usb_rxf => n_usb_rxf,
          usb_wr => usb_wr,
          n_usb_rd => n_usb_rd
        );

   -- Clock process definitions
   clk_process :process
   begin
		clk <= '0';
		wait for clk_period/2;
		clk <= '1';
		wait for clk_period/2;
   end process;
 
	phi_process :process
	begin
		phi2 <= '0';
		wait for C128_clk_period;
		phi2 <= '1';
		wait for C128_clk_period;
	end process;

   -- Stimulus process
   stim_proc: process
   begin
		ba <= 'H';
		n_roml <= 'H';
		n_romh <= 'H';
		n_io1 <= 'H';
		n_io2 <= 'H';
		n_irq <= 'H';
		n_nmi <= 'H';
		n_game <= 'H';
		n_exrom <= 'H';
		n_DMA <= 'H';
		button_a <= '1';
		button_b <= '1';
		button_c <= '1';
		n_usb_txe <= '1';
		n_usb_rxf <= '1';
		addr <= b"1111111111111100";
		data <= b"10101010";
			
      n_reset_io <= '0'; -- 128 holds down reset
		c128_reset_mirror <= '0';
      -- hold reset state for 100 ns.
      wait for 100 ns;	

      wait for C128_clk_period*10;

		n_reset_io <= 'H'; -- 128 releases reset
		c128_reset_mirror <= 'H';
		
      -- insert stimulus here

      wait;
   end process;

END;
2020-05-25 17:13
tlr

Registered: Sep 2003
Posts: 1714
Ok, I personally never use 'H' so I'm not entierly sure what happens. I would probably use 'Z' if I ment pulled up.

That aside you have some signals that are declared as inputs on the ef3 component, but assigned 'H' in your stimulus, e.g ba and n_roml, n_romh to name a few. Maybe this messes things up?

Without looking at the schematic I can see the ef3 component has a memory bus (mem_addr, mem_data) that you just left floating. Maybe it reads stuff from there in which case you would get 'U'/'X'?

You basically need to add some behavioural models for the relevant components connected to the vhdl design like memories and any logic that is there.
There is probably much more to it but that what I see at a glance.
2020-05-25 17:25
oziphantom

Registered: Oct 2014
Posts: 478
Well at the moment, I'm concerned with the Reset_Generator (https://bitbucket.org/skoe/easyflash/src/master/Hardware/ef3-vh..) module, which deals with the reset line and initial set up of the EF3. The 'X's and 'U's are in the reset generator, in that it's own cycle counter becomes "XXX" since doing a -1 on "UUU" gives "XXX" it seems. The reset module doesn't play with or have any settings that cross the mem_bus/mem_addr but I can try pulling them all to 0.

It seems "n_generated_reset: out std_logic; -- reset from host" needs to get triggered which then starts the whole thing off. But since the EF is outputting a '0' on the "n_reset_io" it levels lifts and hence it never gets out of reset.

To me 'Z' means commodore is not driving it, and thus the EF cart will be in control. While 'H' means the commodore is actively pulling it high, just not directly driving it high. I've tried them with 'Z' and got 'X' for my trouble. While a 'U' vs a 'H' seems a 'U' wins..
2020-05-25 17:49
tlr

Registered: Sep 2003
Posts: 1714
Ok, I see what you mean. The reset_generator depends on its port start_reset to start counting and the releasing n_reset_io eventually.

It seems to be gated together from quite a lot of stuff in ef3.vhdl.
2020-05-26 12:15
oziphantom

Registered: Oct 2014
Posts: 478
So ef3.pdf is the Schematic :D

The buttons are special.

in that you have

GND ------- switch --------+--- 4K7 R -- 3v3
    \ 100n C - + - 100K R -|
               |
               +------ inverter -------- CPLD

So a.) 1 means they are active, not "open"
b.) There is a timed delay upon them..

However, it seems to me that start_reset needs to go "1" in order for the cart to kick things off.
reset_boot_or_no_boot: process(n_sys_reset, reset_to_menu, clk)
 begin
        if n_sys_reset = '0' or reset_to_menu = '1' then
            easyflash_boot <= '1';
        elsif rising_edge(clk) then
            start_reset_i <= '0';
            if enable = '1' then
                if button_special_fn = '1' then
                    easyflash_boot <= '0';
                    start_reset_i <= '1';
                elsif button_crt_reset = '1' then
                    easyflash_boot <= '1';
                    start_reset_i <= '1';
                end if;
            end if;
        end if;
    end process;

    start_reset <= start_reset_i;

So the cap + resistor on the buttons will hold the input to the inverter '1' for a bit then the cap will charge and then empty pulling it '0'. Which when inverted means at power on the CPLD sees '0' then '1'. Which would seem to kick everything off. However
    ---------------------------------------------------------------------------
    -- The buttons will be enabled after all buttons have been released one
    -- time. This is done to prevent detection of button presses while the
    -- circuit is powered up.
    ---------------------------------------------------------------------------
    enable_buttons: process(clk)
    begin
        -- todo: Reset?
        if rising_edge(clk) then
            if button_a = '0' and button_b = '0' and
               button_c = '0' then
                buttons_enabled <= '1';
            end if;
        end if;
    end process enable_buttons;
but maybe this is not true? The CPLD boots faster( and is TTL level? ), and the 147K resisters cause a delay on the inverters. so the cart actually gets to see 0,0,0 then 1,1,1 which then drains to 0,0,0 again? The inverters are LVC. Which are Schmitt triggered so there shouldn't be any "meta stable switching", but also CMOS voltage triggered not TTL voltage triggered?
2020-05-26 12:26
chatGPZ

Registered: Dec 2001
Posts: 11108
the cap is just for debounce, not "delay" :)
2020-05-26 13:56
oziphantom

Registered: Oct 2014
Posts: 478
setting all 3 buttons to '0' then waiting 100ns then '1' then waiting for a bit again and setting them to 0. Causes the cart to boot in the simulation. But is it real?

Sure Groepaz the circuit exists to de-bounce the buttons, but does it also cause an unintended delay at boot?
2020-05-26 14:20
tlr

Registered: Sep 2003
Posts: 1714
Don't forget that 'U' isn't something appearing in real life so the three counter bits in reset_generator will have some (valid) initial state.
For Xilinx FPGA technologies a flop with a set input is defined to be synthesized as having the initial state of '1'. I'm assuming this applies to their CPLDs as well.

Judging from the lack of a testbench in the original design I'm guessing it was mostly verified on hardware and not in simulation. You could try adding the initial value of "111" to the counter and see what happens.
2020-05-26 14:42
oziphantom

Registered: Oct 2014
Posts: 478
removing the button state toggling, and setting the counter to am initial state. Does have somethings ok, reset goes to 'Z' for example. But there are still a pile of 'X' and game which is a critical line in the boot process is 'U' so while it might be '0' it is something that needs to be 100% '0' for the cart to boot.

I was also thinking it might be a case of "well in the real world there will be delays between these signals internally so it works fine thanks to them"..
2020-05-26 14:52
Trasher

Registered: Sep 2009
Posts: 8
Quote: Ok, I personally never use 'H' so I'm not entierly sure what happens. I would probably use 'Z' if I ment pulled up.

That aside you have some signals that are declared as inputs on the ef3 component, but assigned 'H' in your stimulus, e.g ba and n_roml, n_romh to name a few. Maybe this messes things up?

Without looking at the schematic I can see the ef3 component has a memory bus (mem_addr, mem_data) that you just left floating. Maybe it reads stuff from there in which case you would get 'U'/'X'?

You basically need to add some behavioural models for the relevant components connected to the vhdl design like memories and any logic that is there.
There is probably much more to it but that what I see at a glance.


If you have a pull-up; H is what you should use to mimic the actual pull-up resistor.

Did not look elsewhere than in what is posted in this thread, but having the *rom* signals as INPUT only also caught my eye. In reality they must be INOUT. I prefer to model things correctly, though it may not matter for this case.
2020-05-27 07:38
oziphantom

Registered: Oct 2014
Posts: 478
By the ROM lines, you mean ROML and ROMH? Why would they need to be an input on the EF3?
2020-05-27 11:52
tlr

Registered: Sep 2003
Posts: 1714
Quote: If you have a pull-up; H is what you should use to mimic the actual pull-up resistor.

Did not look elsewhere than in what is posted in this thread, but having the *rom* signals as INPUT only also caught my eye. In reality they must be INOUT. I prefer to model things correctly, though it may not matter for this case.


Pardon my ignorance, but as I've not used 'H' and 'L' in simulation I have to ask:
What is the result of:
signal a : std_logic := 'H';
signal b : boolean;
...
b <= (a = '1');
...
Will that resolve as true then? If not it will be a problem unless the code is specifically written to handle cases like that.
2020-05-27 12:44
oziphantom

Registered: Oct 2014
Posts: 478
a quick google turns up : No

'1' != 'H'
you need to do
a ?= '1'
see https://books.google.com.au/books?id=iskV16bpYdgC&pg=PA49&lpg=P..
2020-05-27 13:14
tlr

Registered: Sep 2003
Posts: 1714
Quote: a quick google turns up : No

'1' != 'H'
you need to do
a ?= '1'
see https://books.google.com.au/books?id=iskV16bpYdgC&pg=PA49&lpg=P..


If that is the case, you can't just feed anything other than '0' or '1' into something not specifically designed to model that hw behaviour.
We concluded earlier that the code seems written mainly for synthesis into a CPLD implementation, which is reasonable IMO.

Check the condition for ba in freezer.vhdl as an example of a potentially problematic construct.
EDIT: sorry, ba should be fine as it is and:ed. You'll have to look around for ifs.
2020-05-27 15:21
oziphantom

Registered: Oct 2014
Posts: 478
thinking about it 'Z' has just the same flaw. So setting it to 'H' or 'Z' is still going to make an ='1' and ='0' fail.
2020-05-27 15:39
tlr

Registered: Sep 2003
Posts: 1714
Quote: thinking about it 'Z' has just the same flaw. So setting it to 'H' or 'Z' is still going to make an ='1' and ='0' fail.

Yes. Anything other than '1' or '0' needs some kind of handling in the implementation. For inout ports it's reasonable to expect it is handled but maybe not for pure ins.
2020-05-28 09:45
oziphantom

Registered: Oct 2014
Posts: 478
Seems =? was added in VHDL 2008 and ISE only goes up to VHDL 200X.

Forcing reset to '1' gives an 'X' while the cart counts, and then restores to what it needs to be. Adding an extra or = 'H' clause, and setting it to 'H'. Makes all the nasty 'X's go away.

So the fix is, init the counter to a valid value explicitly, add an extra check for 'H' in the reset_generator and set the reset_in to 'H' in the test case. Then it basically boots as expected, few 'U's here and there but they look like they are 'don't care' cases.

Thank you for your help.
2020-05-28 11:16
tlr

Registered: Sep 2003
Posts: 1714
Quote: Seems =? was added in VHDL 2008 and ISE only goes up to VHDL 200X.

Forcing reset to '1' gives an 'X' while the cart counts, and then restores to what it needs to be. Adding an extra or = 'H' clause, and setting it to 'H'. Makes all the nasty 'X's go away.

So the fix is, init the counter to a valid value explicitly, add an extra check for 'H' in the reset_generator and set the reset_in to 'H' in the test case. Then it basically boots as expected, few 'U's here and there but they look like they are 'don't care' cases.

Thank you for your help.


Super! Glad to help.

I'm of the opinion that a testbench, at least a very rudimentary one should be supplied with the design. I'm surprised this wasn't the case.
2020-05-28 12:41
oziphantom

Registered: Oct 2014
Posts: 478
he didn't even provide an ise project file and makes it with a custom make file.
2020-05-28 13:35
chatGPZ

Registered: Dec 2001
Posts: 11108
if the IDE is anything like quartus, thats more than understandable =)
2020-05-28 15:36
oziphantom

Registered: Oct 2014
Posts: 478
It is very "90s" IDE. However it might be more that it only supports "the paid for" linux distros. You can get the IDE to work on Ubuntu/Debian but the simulator just segfaults instantly (for me).
2020-05-28 15:51
chatGPZ

Registered: Dec 2001
Posts: 11108
same with quartus, you need to beat it into shape, copy lots of older binary libs into its directory and fiddle with LD_PRELOAD etc. but i doubt that was the reason, skoe probably just liked makefiles better (and so do i)
2020-05-28 18:33
tlr

Registered: Sep 2003
Posts: 1714
+1 for Makefiles. He probably didn't have a project file himself. And yes, ISE is quite old by now (2013) so it's going to be a pain getting running. Vivado which is the current Xilinx toolset runs ok on Ubuntu 20.04 LTS only needing a few legacy libs apt-getted so that's good.
2020-05-28 19:04
chatGPZ

Registered: Dec 2001
Posts: 11108
i use a quite old quartus (13)... and yuck. i avoid the IDE at all cost :)
2020-05-28 20:12
oziphantom

Registered: Oct 2014
Posts: 478
sure but also iSIM ;) I tried GHDL which will compile the ISE libs, but this project wouldn't run in it, didn't try too hard though.

However if I was making a Windows project and I used nmake I would still give an .sln file even if I didn't use it.
2020-05-28 20:17
tlr

Registered: Sep 2003
Posts: 1714
Quote: sure but also iSIM ;) I tried GHDL which will compile the ISE libs, but this project wouldn't run in it, didn't try too hard though.

However if I was making a Windows project and I used nmake I would still give an .sln file even if I didn't use it.


You should be able to simulate in vivado as long as the project doesn't instantiate any device specific entities. The xsim included in vivado is a lot better than isim.
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Frostbyte/Artline De..
Guests online: 123
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 The Ghost  (9.6)
9 Wonderland XIV  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.8)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 Rainbow Connection  (9.5)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Onscreen 5k  (9.5)
8 Wafer Demo  (9.5)
9 Dawnfall V1.1  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Webmasters
1 Slaygon  (9.7)
2 Perff  (9.6)
3 Morpheus  (9.5)
4 Sabbi  (9.5)
5 CreaMD  (9.1)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.087 sec.