Minimig Discussion Forum

Discussing the Open Source FPGA Amiga Project
It is currently Thu May 23, 2013 3:20 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: ICR fix in CIA8520.v
PostPosted: Wed Jul 21, 2010 4:18 pm 
Offline

Joined: Sun Jan 04, 2009 3:48 am
Posts: 80
Hello,

it is not necessary for the "real" Minmig but it will save some time and hair pulling on some Minimig porting with TG68 core. ;)
Here is the change in the interrut controller :
Code:
//----------------------------------------------------------------------------------
//----------------------------------------------------------------------------------
//interrupt control
//----------------------------------------------------------------------------------
//----------------------------------------------------------------------------------

module ciaint
(
   input    clk,              //clock
   input   rd,               //read enable
   input   wr,               //write enable
   input    reset,             //reset
   input    icrs,            //interrupt control register select
   input   ta,               //ta (set TA bit in ICR register)
   input   tb,                //tb (set TB bit in ICR register)
   input   alrm,             //alrm (set ALRM bit ICR register)
   input    flag,             //flag (set FLG bit in ICR register)
   input    ser,            //ser (set SP bit in ICR register)
   input    [7:0] data_in,      //bus data in
   output    [7:0] data_out,      //bus data out
   output   irq               //intterupt out
);

reg  [4:0] icr;         //interrupt register
reg  [4:0] icrmask;      //interrupt mask register
wire       icr_rd;      //interrupt control register read
reg        icr_rd_dly;  //interrupt control register read delayed

//interrupt control register read
assign icr_rd = icrs & rd;

//interrupt control register read delayed
always @(posedge clk)
   if (reset)
      icr_rd_dly <= 0;
   else
       icr_rd_dly <= icr_rd;

//reading of interrupt data register
assign data_out[7:0] = icr_rd ? {irq,2'b00,icr[4:0]} : 8'b0000_0000;

//writing of interrupt mask register
always @(posedge clk)
   if (reset)
      icrmask[4:0] <= 0;
   else if (icrs && wr)
   begin
      if (data_in[7])
         icrmask[4:0] <= icrmask[4:0] | data_in[4:0];
      else
         icrmask[4:0] <= icrmask[4:0] & (~data_in[4:0]);
   end

//register new interrupts and/or changes by user reads
always @(posedge clk)
   if (reset)//synchronous reset   
      icr[4:0] <= 5'b0_0000;
   else if (!icr_rd && icr_rd_dly)
   begin//clear latched interrupts on end of read
      icr[0] <= ta;         //timer a
      icr[1] <= tb;         //timer b
      icr[2] <= alrm;         //timer tod
      icr[3] <= ser;          //external ser input
      icr[4] <= flag;         //external flag input
   end
   else
   begin//keep latched interrupts
      icr[0] <= icr[0] | ta;      //timer a
      icr[1] <= icr[1] | tb;      //timer b
      icr[2] <= icr[2] | alrm;   //timer tod
      icr[3] <= icr[3] | ser;      //external ser input
      icr[4] <= icr[4] | flag;   //external flag input
   end

//generate irq output (interrupt request)
assign irq    = (icrmask[0] & icr[0])
         | (icrmask[1] & icr[1])
         | (icrmask[2] & icr[2])
         | (icrmask[3] & icr[3])
         | (icrmask[4] & icr[4]);

endmodule

Please note that I added "rd" input in the module. Most of the internal modules of CIA8520.v do not use "rd" but "!wr" to check for read. Why is that ?

Regards,

Frederic


Top
 Profile  
 
 Post subject: Re: ICR fix in CIA8520.v
PostPosted: Thu Jul 22, 2010 10:37 am 
Offline

Joined: Mon Dec 01, 2008 9:58 pm
Posts: 1406
Location: .de
Thanks for your work to Minimig :)
Im sure this solution will help others for porting the core to another FPGA board.
I cant test it or gain any advantage from it, due to oen only the MinimigV1 boards ;)

PS: There is an " input rd, // read enable" text line present in CIA8520.v of YB091224 release.
Otherwise it would not be possible ro read out any keyboard input or CIA register etc.

_________________
__________________________________________________________
JSR $BED ; will guru-meditation until next morning


Top
 Profile  
 
 Post subject: Re: ICR fix in CIA8520.v
PostPosted: Thu Jul 22, 2010 12:46 pm 
Offline

Joined: Sun Jan 04, 2009 3:48 am
Posts: 80
boing4000 wrote:
Thanks for your work to Minimig :)
PS: There is an " input rd, // read enable" text line present in CIA8520.v of YB091224 release.
Otherwise it would not be possible ro read out any keyboard input or CIA register etc.


I am talking about the internal modules : timera, timerb, timerd, etc...
The read decoding is done using : ~wr or !wr, rd is not used.

Something else also to get a cleaner code : we should not use "side" (paula, floppy), "in", "out" (blitter) as signal names in the module interface.
They are reserved keywords in VHDL. This is causing issue in a design with a mix of Verilog and VHDL code (like mine).

Regards,

Frederic


Top
 Profile  
 
 Post subject: Re: ICR fix in CIA8520.v
PostPosted: Fri Jul 23, 2010 1:05 pm 
Offline

Joined: Tue May 05, 2009 11:53 am
Posts: 8
Location: France
Thanks for your work too.
I've been working on a Minimig port for Nios II cyclone III dev kit but I stopped a few month ago.
I experienced difficulties with the floppy device too. So I began working with the DE2's IDE controller (the tobiflex port). But I've not finished to integrate it yet.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Translated by Xaphos © 2007, 2008, 2009 phpBB.fr