Skip to content

Commit

Permalink
Fix the generation of mem with 1 bit of write mask
Browse files Browse the repository at this point in the history
  • Loading branch information
Dolu1990 committed Jan 13, 2025
1 parent 2c93394 commit 2977ef3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1311,16 +1311,13 @@ end
def emitWrite(b: StringBuilder, mem: Mem[_], writeEnable: String, address: Expression, data: Expression, mask: Expression with WidthProvider, symbolCount: Int, bitPerSymbole: Int, tab: String): Unit = {

if(memBitsMaskKind == SINGLE_RAM || symbolCount == 1) {
val ramAssign = s"$tab${emitReference(mem, false)}[${emitExpression(address)}] <= ${emitExpression(data)};\n"

if (writeEnable != null) {
b ++= s"${tab}if(${writeEnable}) begin\n "
b ++= ramAssign
b ++= s"${tab}end\n"
} else {
b ++= ramAssign
}

val ramAssign = s"$tab ${emitReference(mem, false)}[${emitExpression(address)}] <= ${emitExpression(data)};\n"
var conds = if(writeEnable != null) List(writeEnable) else Nil
if(mask != null)
conds = s"${emitExpression(mask)}[0]" :: conds
if(conds.nonEmpty) b ++= s"${tab}if(${conds.mkString(" && ")}) begin\n"
b ++= ramAssign
if(conds.nonEmpty) b ++= s"${tab}end\n"
} else {

def maskCount = mask.getWidth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1153,15 +1153,12 @@ class ComponentEmitterVhdl(
def emitWrite(b: StringBuilder, mem: Mem[_], writeEnable: String, address: Expression, data: Expression, mask: Expression with WidthProvider, symbolCount: Int, bitPerSymbole: Int, tab: String): Unit = {
if(memBitsMaskKind == SINGLE_RAM || symbolCount == 1) {
val ramAssign = s"$tab${emitReference(mem, false)}(to_integer(${emitExpression(address)})) <= ${emitExpression(data)};\n"

if (writeEnable != null) {
b ++= s"${tab}if ${writeEnable} then\n "
b ++= ramAssign
b ++= s"${tab}end if;\n"
} else {
b ++= ramAssign
}

var conds = if(writeEnable != null) List(writeEnable) else Nil
if(mask != null)
conds = s"${emitExpression(mask)}(0) = '1'" :: conds
if(conds.nonEmpty) b ++= s"${tab}if ${conds.mkString(" and ")} then\n"
b ++= ramAssign
if(conds.nonEmpty) b ++= s"${tab}end if;\n"
} else {

def maskCount = mask.getWidth
Expand Down

0 comments on commit 2977ef3

Please sign in to comment.