Skip to content
This repository has been archived by the owner on Sep 18, 2019. It is now read-only.

Commit

Permalink
Merge pull request #40 from unihd-cag/iss39
Browse files Browse the repository at this point in the history
iss39 Implemeted edge triggered counter
  • Loading branch information
TM90 committed Mar 26, 2015
2 parents 5d5456c + 01f5554 commit 760e6b9
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 66 deletions.
8 changes: 0 additions & 8 deletions tcl/address-hierarchical/address-hierarchical.tm
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,6 @@ namespace eval osys::rfg::address::hierarchical {
set blockAddress 0
foreach it $value {

::puts "Debug Addressing: [$it name]"
::puts "current: $currentAddress"
::puts "BaseAddress: $baseAddress"
if {$it==$key} {
continue
}
Expand All @@ -255,16 +252,11 @@ namespace eval osys::rfg::address::hierarchical {
set itSize [sizeOf $it]
if {$itSize == 0} {

::puts "Current position aligner: $currentAddress"
::puts "Aligment: [$it aligment]"
if {$currentAddress == 0} {
set blockAddress [$it aligment]
} else {
::puts "Else"
::puts "[expr int($currentAddress/[$it aligment]+1)]"
set blockAddress [expr int($currentAddress/[$it aligment]+1)*[$it aligment]]
}
::puts "Block Address Aligner $blockAddress"
set currentAddress $blockAddress

} else {
Expand Down
31 changes: 27 additions & 4 deletions tcl/generator-verilog/registerfile_template.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ odfi::closures::oproc writeRegisterInterface {it} {
$it onAttributes {hardware.osys::rfg::software_written} {
output [getName $it]_written [find_internalRF $it $rf]
}

input [getName $it]_countup wire
$it onAttributes {hardware.osys::rfg::edge_trigger} {
input [getName $it]_edge wire
} otherwise {
input [getName $it]_countup wire
}

} otherwise {

Expand Down Expand Up @@ -198,7 +201,7 @@ odfi::closures::oproc writeRegisterInternalSigs {it} {
} otherwise {

$it onEachField {
::if {[$it name] != "Reserved"} {
if {[$it name] != "Reserved"} {
$it onAttributes {hardware.osys::rfg::counter} {

## Check if this is equivilant
Expand All @@ -211,8 +214,12 @@ odfi::closures::oproc writeRegisterInternalSigs {it} {
reg [getName $it]_load_value [$it width]
}
}
$it onAttributes {hardware.osys::rfg::edge_trigger} {
reg [getName $it]_countup
reg [getName $it]_edge_last
}

::if {![$it hasAttribute hardware.osys::rfg::ro] && \
if {![$it hasAttribute hardware.osys::rfg::ro] && \
![$it hasAttribute hardware.osys::rfg::rw]} {
wire [getName $it] [$it width]
}
Expand Down Expand Up @@ -415,6 +422,11 @@ odfi::closures::oproc writeRegisterReset {object} {
}
}

$it onAttributes {hardware.osys::rfg::edge_trigger} {
vputs "[getName $it]_edge_last <= 1'b0"
vputs "[getName $it]_countup <= 1'b0"
}

} ohterwise {
if {[$it name] != "Reserved"} {
vputs "[getName $it] <= [$it reset]"
Expand Down Expand Up @@ -457,6 +469,17 @@ odfi::closures::oproc writeRegisterWrite {object} {
}

incr offset [$it width]

$it onAttributes {hardware.osys::rfg::edge_trigger} {
set obj $it
vif "[getName $obj]_edge != [getName $obj]_edge_last" {
vputs "[getName $obj]_countup <= 1'b1"
vputs "[getName $obj]_edge_last <= [getName $obj]_edge"
}
velse {
vputs "[getName $obj]_countup <= 1'b0"
}
}

}
}
Expand Down
1 change: 1 addition & 0 deletions tcl/rfgfunctions.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ attributeFunction ::internal
attributeFunction ::clear
attributeFunction ::write_clear
attributeFunction ::shared_bus
attributeFunction ::edge_trigger

## Addressing
attributeFunction ::relative_address
Expand Down
114 changes: 60 additions & 54 deletions xsl/rfs-to-rfg.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ registerFile <xsl:value-of select="@name"/> {

<!-- depth -->
<xsl:if test="@addrsize">
<xsl:value-of select="$hier-level-tab"/> depth [expr pow(2,<xsl:value-of select="@addrsize"/>)]
<xsl:value-of select="$hier-level-tab"/> depth [expr int(pow(2,<xsl:value-of select="@addrsize"/>))]
<xsl:text>

</xsl:text>
Expand All @@ -134,32 +134,36 @@ registerFile <xsl:value-of select="@name"/> {
<!-- Special Attributes -->
<!-- ################### -->
<xsl:if test="@counter">
<xsl:value-of select="$hier-level-tab-more"/> counter
<xsl:value-of select="$hier-level-tab-more"/> counter
</xsl:if>
<xsl:text>
</xsl:text>
<xsl:if test="@counter='2'">
<xsl:value-of select="$hier-level-tab-more"/> edge_trigger
</xsl:if>
<xsl:text>
</xsl:text>
<xsl:if test="@rreinit">
<xsl:value-of select="$hier-level-tab-more"/> rreinit
<xsl:value-of select="$hier-level-tab-more"/> rreinit
</xsl:if>
<xsl:text>
</xsl:text>
<xsl:if test="@sw_written">
<xsl:value-of select="$hier-level-tab-more"/> software_written <xsl:value-of select="@sw_written"></xsl:value-of>
<xsl:text>
</xsl:text>
<xsl:value-of select="$hier-level-tab-more"/> software_written <xsl:value-of select="@sw_written"></xsl:value-of>
</xsl:if>
<xsl:text>
</xsl:text>
<xsl:if test="not(@hw_wen) and not(@counter)">
<xsl:value-of select="$hier-level-tab-more"/>no_wen
<xsl:text>
</xsl:text>
<xsl:value-of select="$hier-level-tab-more"/> no_wen
</xsl:if>
<xsl:text>
</xsl:text>
<xsl:if test="@external">
<xsl:value-of select="$hier-level-tab-more"/>external
<xsl:text>
</xsl:text>
<xsl:value-of select="$hier-level-tab-more"/> external
</xsl:if>
<xsl:text>
</xsl:text>
</xsl:text>
<xsl:value-of select="$hier-level-tab-more"/>}

<xsl:text>
</xsl:text>
}

<xsl:apply-templates />
Expand Down Expand Up @@ -272,80 +276,82 @@ registerFile <xsl:value-of select="@name"/> {
<xsl:when test="fn:matches(@width,'^[A-Z_]+')">width $<xsl:value-of select="@width"/></xsl:when>
<xsl:otherwise>width <xsl:value-of select="@width"/></xsl:otherwise>
</xsl:choose>
<xsl:text>
</xsl:text>

<!-- Reset -->
<xsl:text>
</xsl:text>
<xsl:value-of select="$hier-level-tab-more"/><xsl:choose>
<xsl:when test="fn:matches(@reset,'^[A-Z_]+')">reset $<xsl:value-of select="@reset"/></xsl:when>
<xsl:otherwise>reset <xsl:value-of select="@reset"/></xsl:otherwise>
</xsl:choose>

<xsl:text>
</xsl:text>

<xsl:text>
</xsl:text>
<!-- Rights and attributes-->
<xsl:value-of select="$hier-level-tab-more"/>software {
<xsl:value-of select="$hier-level-tab-more"/> <xsl:value-of select="@sw"/>
<xsl:text>
</xsl:text>
</xsl:text>
<!-- Special Attributes -->
<!-- ################### -->
<xsl:if test="@sw_write_clr">
<xsl:value-of select="$hier-level-tab-more"/>write_clear
<xsl:value-of select="$hier-level-tab-more"/> write_clear
</xsl:if>
<xsl:text>
</xsl:text>
<xsl:if test="@sw_write_xor">
<xsl:value-of select="$hier-level-tab-more"/>write_xor
<xsl:value-of select="$hier-level-tab-more"/> write_xor
</xsl:if>
<xsl:text>
</xsl:text>
</xsl:text>
<xsl:value-of select="$hier-level-tab-more"/>}

<xsl:text>
</xsl:text>

<xsl:text>
</xsl:text>
<xsl:value-of select="$hier-level-tab-more"/>hardware {

<xsl:value-of select="$hier-level-tab-more"/> <xsl:value-of select="@hw"/>
<xsl:text>
</xsl:text>
<!-- Special Attributes -->
<!-- ################### -->
<xsl:text>
</xsl:text>
<xsl:if test="@counter">
<xsl:value-of select="$hier-level-tab-more"/> counter
<xsl:value-of select="$hier-level-tab-more"/> counter
</xsl:if>
<xsl:text>
</xsl:text>
<xsl:if test="@counter='2'">
<xsl:value-of select="$hier-level-tab-more"/> edge_trigger
</xsl:if>
<xsl:text>
</xsl:text>
<xsl:if test="@rreinit">
<xsl:value-of select="$hier-level-tab-more"/> rreinit
<xsl:value-of select="$hier-level-tab-more"/> rreinit
</xsl:if>
<xsl:text>
</xsl:text>
<xsl:if test="@sw_written">
<xsl:value-of select="$hier-level-tab-more"/> software_written <xsl:value-of select="@sw_written"></xsl:value-of>
<xsl:text>
</xsl:text>
<xsl:value-of select="$hier-level-tab-more"/> software_written <xsl:value-of select="@sw_written"></xsl:value-of>
</xsl:if>
<xsl:text>
</xsl:text>
<xsl:if test="not(@hw_wen) and not(@counter)">
<xsl:value-of select="$hier-level-tab-more"/>no_wen
<xsl:value-of select="$hier-level-tab-more"/> no_wen
</xsl:if>
<xsl:text>
</xsl:text>
</xsl:text>
<xsl:if test="@hw_clr">
<xsl:value-of select="$hier-level-tab-more"/>clear
</xsl:if>
<xsl:value-of select="$hier-level-tab-more"/> clear
</xsl:if>
<xsl:text>
</xsl:text>
</xsl:text>
<xsl:if test="@sticky">
<xsl:value-of select="$hier-level-tab-more"/>sticky
</xsl:if>
<xsl:value-of select="$hier-level-tab-more"/> sticky
</xsl:if>
<xsl:text>
</xsl:text>
<xsl:value-of select="$hier-level-tab-more"/>}

<xsl:text>
</xsl:text>

</xsl:text>
<xsl:value-of select="$hier-level-tab-more"/>}
<xsl:text>
</xsl:text>
<xsl:value-of select="$hier-level-tab"/>}

<xsl:text>
</xsl:text>
</xsl:template>
<!-- ################## -->
<!-- Reserved -->
Expand Down Expand Up @@ -429,4 +435,4 @@ registerFile <xsl:value-of select="@name"/> {
<!-- Ignores -->
<!-- ######## -->
<xsl:template match="node()"></xsl:template>
</xsl:stylesheet>
</xsl:stylesheet>

0 comments on commit 760e6b9

Please sign in to comment.