Line 1... |
Line 1... |
################################################################################
|
################################################################################
|
#
|
#
|
# Copyright 2013, Sinclair R.F., Inc.
|
# Copyright 2013-2014, Sinclair R.F., Inc.
|
#
|
#
|
################################################################################
|
################################################################################
|
|
|
import math
|
import math
|
import re;
|
import re;
|
Line 199... |
Line 199... |
'error',
|
'error',
|
'synchronous',
|
'synchronous',
|
):
|
):
|
if not hasattr(self,paramname):
|
if not hasattr(self,paramname):
|
raise SSBCCException('Required parameter "%s" is missing at %s' % (paramname,loc,));
|
raise SSBCCException('Required parameter "%s" is missing at %s' % (paramname,loc,));
|
|
# Ensure exclusive pair configurations are set and consistent.
|
|
for exclusivepair in (
|
|
('write_enable','noWSTRB',None,None,),
|
|
):
|
|
if hasattr(self,exclusivepair[0]) and hasattr(self,exclusivepair[1]):
|
|
raise SSBCCException('Only one of "%s" and "%s" can be specified at %s' % (exclusivepair[0],exclusivepair[1],loc,));
|
|
if not hasattr(self,exclusivepair[0]) and not hasattr(self,exclusivepair[1]) and exclusivepair[2]:
|
|
setattr(self,exclusivepair[2],exclusivepair[3]);
|
# Ensure one and only one of the complementary optional values are set.
|
# Ensure one and only one of the complementary optional values are set.
|
if not hasattr(self,'write_enable') and not hasattr(self,'noWSTRB'):
|
if not hasattr(self,'write_enable') and not hasattr(self,'noWSTRB'):
|
raise SSBCCException('One of "write_enable" or "noWSTRB" must be set at %s' % loc);
|
raise SSBCCException('One of "write_enable" or "noWSTRB" must be set at %s' % loc);
|
if hasattr(self,'write_enable') and hasattr(self,'noWSTRB'):
|
|
raise SSBCCException('Only one of "write_enable" or "noWSTRB" can be set at %s' % loc);
|
|
self.noWSTRB = hasattr(self,'noWSTRB');
|
|
# Temporary: Warning message
|
# Temporary: Warning message
|
if not self.synchronous:
|
if not self.synchronous:
|
raise SSBCCException('synchronous=False has not been validated yet');
|
raise SSBCCException('synchronous=False has not been validated yet');
|
# Add the I/O port, internal signals, and the INPORT and OUTPORT symbols for this peripheral.
|
# Add the I/O port, internal signals, and the INPORT and OUTPORT symbols for this peripheral.
|
for signal in (
|
for signal in (
|
( 'i_%s_aresetn', 1, 'input', ),
|
( '%s_aresetn', 1, 'input', ),
|
( 'i_%s_aclk', 1, 'input', ),
|
( '%s_aclk', 1, 'input', ),
|
( 'o_%s_awvalid', 1, 'output', ),
|
( '%s_awvalid', 1, 'output', ),
|
( 'i_%s_awready', 1, 'input', ),
|
( '%s_awready', 1, 'input', ),
|
( 'o_%s_awaddr', self.address_width, 'output', ),
|
( '%s_awaddr', self.address_width, 'output', ),
|
( 'o_%s_wvalid', 1, 'output', ),
|
( '%s_wvalid', 1, 'output', ),
|
( 'i_%s_wready', 1, 'input', ),
|
( '%s_wready', 1, 'input', ),
|
( 'o_%s_wdata', 32, 'output', ),
|
( '%s_wdata', 32, 'output', ),
|
( 'o_%s_wstrb', 4, 'output', ) if not self.noWSTRB else None,
|
( '%s_wstrb', 4, 'output', ) if hasattr(self,'write_enable') else None,
|
( 'i_%s_bresp', 2, 'input', ),
|
( '%s_bresp', 2, 'input', ),
|
( 'i_%s_bvalid', 1, 'input', ),
|
( '%s_bvalid', 1, 'input', ),
|
( 'o_%s_bready', 1, 'output', ),
|
( '%s_bready', 1, 'output', ),
|
( 'o_%s_arvalid', 1, 'output', ),
|
( '%s_arvalid', 1, 'output', ),
|
( 'i_%s_arready', 1, 'input', ),
|
( '%s_arready', 1, 'input', ),
|
( 'o_%s_araddr', self.address_width, 'output', ),
|
( '%s_araddr', self.address_width, 'output', ),
|
( 'i_%s_rvalid', 1, 'input', ),
|
( '%s_rvalid', 1, 'input', ),
|
( 'o_%s_rready', 1, 'output', ),
|
( '%s_rready', 1, 'output', ),
|
( 'i_%s_rdata', 32, 'input', ),
|
( '%s_rdata', 32, 'input', ),
|
( 'i_%s_rresp', 2, 'input', ),
|
( '%s_rresp', 2, 'input', ),
|
):
|
):
|
if not signal:
|
if not signal:
|
continue
|
continue
|
thisName = signal[0] % self.basePortName;
|
thisName = signal[0] % self.basePortName;
|
config.AddIO(thisName,signal[1],signal[2],loc);
|
config.AddIO(thisName,signal[1],signal[2],loc);
|
Line 248... |
Line 253... |
),loc);
|
),loc);
|
self.ix_data = config.NOutports();
|
self.ix_data = config.NOutports();
|
config.AddOutport((self.data,False,
|
config.AddOutport((self.data,False,
|
# empty list -- disable normal output port signal generation
|
# empty list -- disable normal output port signal generation
|
),loc);
|
),loc);
|
if not self.noWSTRB:
|
if hasattr(self,'write_enable'):
|
config.AddOutport((self.write_enable,False,
|
config.AddOutport((self.write_enable,False,
|
('o_%s_wstrb' % self.basePortName, 4, 'data', ),
|
('%s_wstrb' % self.basePortName, 4, 'data', ),
|
),loc);
|
),loc);
|
config.AddOutport((self.command_read,True,
|
config.AddOutport((self.command_read,True,
|
('s__%s__rd' % self.basePortName, 1, 'strobe', ),
|
('s__%s__rd' % self.basePortName, 1, 'strobe', ),
|
),loc);
|
),loc);
|
config.AddOutport((self.command_write,True,
|
config.AddOutport((self.command_write,True,
|
Line 276... |
Line 281... |
# avoid i_clk and i_rst
|
# avoid i_clk and i_rst
|
for subpair in (
|
for subpair in (
|
(r'\bgen__', 'gen__@NAME@__', ),
|
(r'\bgen__', 'gen__@NAME@__', ),
|
(r'\bL__', 'L__@NAME@__', ),
|
(r'\bL__', 'L__@NAME@__', ),
|
(r'\bs__', 's__@NAME@__', ),
|
(r'\bs__', 's__@NAME@__', ),
|
(r'\bi_a', 'i_@NAME@_a', ),
|
( r'\bi_a', '@NAME@_a', ),
|
(r'\bi_b', 'i_@NAME@_b', ),
|
( r'\bi_b', '@NAME@_b', ),
|
(r'\bi_rd', 'i_@NAME@_rd', ),
|
( r'\bi_rd', '@NAME@_rd', ),
|
(r'\bi_rr', 'i_@NAME@_rr', ),
|
( r'\bi_rr', '@NAME@_rr', ),
|
(r'\bi_rv', 'i_@NAME@_rv', ),
|
( r'\bi_rv', '@NAME@_rv', ),
|
(r'\bi_w', 'i_@NAME@_w', ),
|
( r'\bi_w', '@NAME@_w', ),
|
(r'\bo_', 'o_@NAME@_', ),
|
( r'\bo_', '@NAME@_', ),
|
(r'@ADDRESS_WIDTH@', str(self.address_width), ),
|
(r'@ADDRESS_WIDTH@', str(self.address_width), ),
|
(r'@ISSYNC@', "1'b1" if self.synchronous else "1'b0", ),
|
(r'@ISSYNC@', "1'b1" if self.synchronous else "1'b0", ),
|
(r'@IX_ADDRESS@', str(self.ix_address), ),
|
(r'@IX_ADDRESS@', str(self.ix_address), ),
|
(r'@IX_DATA@', str(self.ix_data), ),
|
(r'@IX_DATA@', str(self.ix_data), ),
|
(r'@IX_READ@', str(self.ix_read), ),
|
(r'@IX_READ@', str(self.ix_read), ),
|
Line 294... |
Line 299... |
):
|
):
|
body = re.sub(subpair[0],subpair[1],body);
|
body = re.sub(subpair[0],subpair[1],body);
|
body = self.GenVerilogFinal(config,body);
|
body = self.GenVerilogFinal(config,body);
|
fp.write(body);
|
fp.write(body);
|
|
|
# Write the TCL script to facilitate creating Vivado IP for the port.
|
|
vivadoFile = os.path.join(os.path.dirname(self.peripheralFile),'vivado_AXI4_Lite_Bus.py');
|
|
execfile(vivadoFile,globals());
|
|
WriteTclScript('master',self.basePortName,self.address_width,noWSTRB=self.noWSTRB);
|
|
|
|
No newline at end of file
|
No newline at end of file
|