aboutsummaryrefslogtreecommitdiffstats
path: root/techlibs
diff options
context:
space:
mode:
authorMarcelina Koƛcielnicka <mwk@0x04.net>2021-01-25 13:01:24 +0100
committerMarcelina Koƛcielnicka <mwk@0x04.net>2021-01-27 00:32:00 +0100
commitcd6f0732f3b342938a915951bdcd5299576f1843 (patch)
tree48110ce80a026fa8161d6e7bc8be4e34c463a657 /techlibs
parenta77fa6709ba893deb30d962618ffa7d5828e74d5 (diff)
downloadyosys-cd6f0732f3b342938a915951bdcd5299576f1843.tar.gz
yosys-cd6f0732f3b342938a915951bdcd5299576f1843.tar.bz2
yosys-cd6f0732f3b342938a915951bdcd5299576f1843.zip
xilinx: Add FDRSE_1, FDCPE_1.
Diffstat (limited to 'techlibs')
-rw-r--r--techlibs/xilinx/cells_sim.v80
1 files changed, 80 insertions, 0 deletions
diff --git a/techlibs/xilinx/cells_sim.v b/techlibs/xilinx/cells_sim.v
index adaf7aee1..a079f1c95 100644
--- a/techlibs/xilinx/cells_sim.v
+++ b/techlibs/xilinx/cells_sim.v
@@ -633,6 +633,41 @@ module FDRSE (
Q <= d;
endmodule
+module FDRSE_1 (
+ output reg Q,
+ (* clkbuf_sink *)
+ (* invertible_pin = "IS_C_INVERTED" *)
+ input C,
+ (* invertible_pin = "IS_CE_INVERTED" *)
+ input CE,
+ (* invertible_pin = "IS_D_INVERTED" *)
+ input D,
+ (* invertible_pin = "IS_R_INVERTED" *)
+ input R,
+ (* invertible_pin = "IS_S_INVERTED" *)
+ input S
+);
+ parameter [0:0] INIT = 1'b0;
+ parameter [0:0] IS_C_INVERTED = 1'b0;
+ parameter [0:0] IS_CE_INVERTED = 1'b0;
+ parameter [0:0] IS_D_INVERTED = 1'b0;
+ parameter [0:0] IS_R_INVERTED = 1'b0;
+ parameter [0:0] IS_S_INVERTED = 1'b0;
+ initial Q <= INIT;
+ wire c = C ^ IS_C_INVERTED;
+ wire ce = CE ^ IS_CE_INVERTED;
+ wire d = D ^ IS_D_INVERTED;
+ wire r = R ^ IS_R_INVERTED;
+ wire s = S ^ IS_S_INVERTED;
+ always @(negedge c)
+ if (r)
+ Q <= 0;
+ else if (s)
+ Q <= 1;
+ else if (ce)
+ Q <= d;
+endmodule
+
(* abc9_box, lib_whitebox *)
module FDCE (
output reg Q,
@@ -837,6 +872,51 @@ module FDCPE (
assign Q = qs ? qp : qc;
endmodule
+module FDCPE_1 (
+ output wire Q,
+ (* clkbuf_sink *)
+ (* invertible_pin = "IS_C_INVERTED" *)
+ input C,
+ input CE,
+ (* invertible_pin = "IS_CLR_INVERTED" *)
+ input CLR,
+ input D,
+ (* invertible_pin = "IS_PRE_INVERTED" *)
+ input PRE
+);
+ parameter [0:0] INIT = 1'b0;
+ parameter [0:0] IS_C_INVERTED = 1'b0;
+ parameter [0:0] IS_CLR_INVERTED = 1'b0;
+ parameter [0:0] IS_PRE_INVERTED = 1'b0;
+ wire c = C ^ IS_C_INVERTED;
+ wire clr = CLR ^ IS_CLR_INVERTED;
+ wire pre = PRE ^ IS_PRE_INVERTED;
+ // Hacky model to avoid simulation-synthesis mismatches.
+ reg qc, qp, qs;
+ initial qc = INIT;
+ initial qp = INIT;
+ initial qs = 0;
+ always @(negedge c, posedge clr) begin
+ if (clr)
+ qc <= 0;
+ else if (CE)
+ qc <= D;
+ end
+ always @(negedge c, posedge pre) begin
+ if (pre)
+ qp <= 1;
+ else if (CE)
+ qp <= D;
+ end
+ always @* begin
+ if (clr)
+ qs <= 0;
+ else if (pre)
+ qs <= 1;
+ end
+ assign Q = qs ? qp : qc;
+endmodule
+
module LDCE (
output reg Q,
(* invertible_pin = "IS_CLR_INVERTED" *)
5'>235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889
/*
 * Privileged operation "API" handling functions.
 * 
 * Copyright (C) 2004 Hewlett-Packard Co.
 *	Dan Magenheimer (dan.magenheimer@hp.com)
 *
 */

#include <asm/privop.h>
#include <asm/vcpu.h>
#include <asm/processor.h>
#include <asm/delay.h>		// Debug only
#include <asm/dom_fw.h>
#include <asm/vhpt.h>
#include <asm/bundle.h>
#include <asm/debugger.h>
#include <xen/perfc.h>

static const long priv_verbose = 0;

/* Set to 1 to handle privified instructions from the privify tool. */
#ifndef CONFIG_PRIVIFY
static const int privify_en = 0;
#else
static const int privify_en = 1;
#endif

/**************************************************************************
Privileged operation emulation routines
**************************************************************************/

static IA64FAULT priv_rfi(VCPU * vcpu, INST64 inst)
{
	REGS *regs = vcpu_regs(vcpu);
	if (PSCB(vcpu, ifs) > 0x8000000000000000UL
	    && regs->cr_ifs > 0x8000000000000000UL) {
		panic_domain(regs,
			     "rfi emulation with double uncover is "
			     "impossible - use hyperprivop\n"
			     " ip=0x%lx vifs=0x%lx ifs=0x%lx\n",
			     regs->cr_iip, PSCB(vcpu, ifs), regs->cr_ifs);
	}
	return vcpu_rfi(vcpu);
}

static IA64FAULT priv_bsw0(VCPU * vcpu, INST64 inst)
{
	return vcpu_bsw0(vcpu);
}

static IA64FAULT priv_bsw1(VCPU * vcpu, INST64 inst)
{
	return vcpu_bsw1(vcpu);
}

static IA64FAULT priv_cover(VCPU * vcpu, INST64 inst)
{
	return vcpu_cover(vcpu);
}

static IA64FAULT priv_ptc_l(VCPU * vcpu, INST64 inst)
{
	u64 vadr = vcpu_get_gr(vcpu, inst.M45.r3);
	u64 log_range;

	log_range = ((vcpu_get_gr(vcpu, inst.M45.r2) & 0xfc) >> 2);
	return vcpu_ptc_l(vcpu, vadr, log_range);
}

static IA64FAULT priv_ptc_e(VCPU * vcpu, INST64 inst)
{
	unsigned int src = inst.M28.r3;

	// NOTE: ptc_e with source gr > 63 is emulated as a fc r(y-64)
	if (privify_en && src > 63)
		return vcpu_fc(vcpu, vcpu_get_gr(vcpu, src - 64));
	return vcpu_ptc_e(vcpu, vcpu_get_gr(vcpu, src));
}

static IA64FAULT priv_ptc_g(VCPU * vcpu, INST64 inst)
{
	u64 vadr = vcpu_get_gr(vcpu, inst.M45.r3);
	u64 addr_range;

	addr_range = 1 << ((vcpu_get_gr(vcpu, inst.M45.r2) & 0xfc) >> 2);
	return vcpu_ptc_g(vcpu, vadr, addr_range);
}

static IA64FAULT priv_ptc_ga(VCPU * vcpu, INST64 inst)
{
	u64 vadr = vcpu_get_gr(vcpu, inst.M45.r3);
	u64 addr_range;

	addr_range = 1 << ((vcpu_get_gr(vcpu, inst.M45.r2) & 0xfc) >> 2);
	return vcpu_ptc_ga(vcpu, vadr, addr_range);
}

static IA64FAULT priv_ptr_d(VCPU * vcpu, INST64 inst)
{
	u64 vadr = vcpu_get_gr(vcpu, inst.M45.r3);
	u64 log_range;

	log_range = (vcpu_get_gr(vcpu, inst.M45.r2) & 0xfc) >> 2;
	return vcpu_ptr_d(vcpu, vadr, log_range);
}

static IA64FAULT priv_ptr_i(VCPU * vcpu, INST64 inst)
{
	u64 vadr = vcpu_get_gr(vcpu, inst.M45.r3);
	u64 log_range;

	log_range = (vcpu_get_gr(vcpu, inst.M45.r2) & 0xfc) >> 2;
	return vcpu_ptr_i(vcpu, vadr, log_range);
}

static IA64FAULT priv_tpa(VCPU * vcpu, INST64 inst)
{
	u64 padr;
	unsigned int fault;
	unsigned int src = inst.M46.r3;

	// NOTE: tpa with source gr > 63 is emulated as a ttag rx=r(y-64)
	if (privify_en && src > 63)
		fault = vcpu_ttag(vcpu, vcpu_get_gr(vcpu, src - 64), &padr);
	else
		fault = vcpu_tpa(vcpu, vcpu_get_gr(vcpu, src), &padr);
	if (fault == IA64_NO_FAULT)
		return vcpu_set_gr(vcpu, inst.M46.r1, padr, 0);
	else
		return fault;
}

static IA64FAULT priv_tak(VCPU * vcpu, INST64 inst)
{
	u64 key;
	unsigned int fault;
	unsigned int src = inst.M46.r3;

	// NOTE: tak with source gr > 63 is emulated as a thash rx=r(y-64)
	if (privify_en && src > 63)
		fault = vcpu_thash(vcpu, vcpu_get_gr(vcpu, src - 64), &key);
	else
		fault = vcpu_tak(vcpu, vcpu_get_gr(vcpu, src), &key);
	if (fault == IA64_NO_FAULT)
		return vcpu_set_gr(vcpu, inst.M46.r1, key, 0);
	else
		return fault;
}

/************************************
 * Insert translation register/cache
************************************/

static IA64FAULT priv_itr_d(VCPU * vcpu, INST64 inst)
{
	u64 fault, itir, ifa, pte, slot;

	//if (!vcpu_get_psr_ic(vcpu))
	//      return IA64_ILLOP_FAULT;
	fault = vcpu_get_itir(vcpu, &itir);
	if (fault != IA64_NO_FAULT)
		return IA64_ILLOP_FAULT;
	fault = vcpu_get_ifa(vcpu, &ifa);
	if (fault != IA64_NO_FAULT)
		return IA64_ILLOP_FAULT;
	pte = vcpu_get_gr(vcpu, inst.M42.r2);
	slot = vcpu_get_gr(vcpu, inst.M42.r3);

	return vcpu_itr_d(vcpu, slot, pte, itir, ifa);
}

static IA64FAULT priv_itr_i(VCPU * vcpu, INST64 inst)
{
	u64 fault, itir, ifa, pte, slot;

	//if (!vcpu_get_psr_ic(vcpu)) return IA64_ILLOP_FAULT;
	fault = vcpu_get_itir(vcpu, &itir);
	if (fault != IA64_NO_FAULT)
		return IA64_ILLOP_FAULT;
	fault = vcpu_get_ifa(vcpu, &ifa);
	if (fault != IA64_NO_FAULT)
		return IA64_ILLOP_FAULT;
	pte = vcpu_get_gr(vcpu, inst.M42.r2);
	slot = vcpu_get_gr(vcpu, inst.M42.r3);

	return vcpu_itr_i(vcpu, slot, pte, itir, ifa);
}

static IA64FAULT priv_itc_d(VCPU * vcpu, INST64 inst)
{
	u64 fault, itir, ifa, pte;

	//if (!vcpu_get_psr_ic(vcpu)) return IA64_ILLOP_FAULT;
	fault = vcpu_get_itir(vcpu, &itir);
	if (fault != IA64_NO_FAULT)
		return IA64_ILLOP_FAULT;
	fault = vcpu_get_ifa(vcpu, &ifa);
	if (fault != IA64_NO_FAULT)
		return IA64_ILLOP_FAULT;
	pte = vcpu_get_gr(vcpu, inst.M41.r2);

	return vcpu_itc_d(vcpu, pte, itir, ifa);
}

static IA64FAULT priv_itc_i(VCPU * vcpu, INST64 inst)
{
	u64 fault, itir, ifa, pte;

	//if (!vcpu_get_psr_ic(vcpu)) return IA64_ILLOP_FAULT;
	fault = vcpu_get_itir(vcpu, &itir);
	if (fault != IA64_NO_FAULT)
		return IA64_ILLOP_FAULT;
	fault = vcpu_get_ifa(vcpu, &ifa);
	if (fault != IA64_NO_FAULT)
		return IA64_ILLOP_FAULT;
	pte = vcpu_get_gr(vcpu, inst.M41.r2);

	return vcpu_itc_i(vcpu, pte, itir, ifa);
}

/*************************************
 * Moves to semi-privileged registers
*************************************/

static IA64FAULT priv_mov_to_ar_imm(VCPU * vcpu, INST64 inst)
{
	// I27 and M30 are identical for these fields
	u64 ar3 = inst.M30.ar3;
	u64 imm = vcpu_get_gr(vcpu, inst.M30.imm);
	return vcpu_set_ar(vcpu, ar3, imm);
}

static IA64FAULT priv_mov_to_ar_reg(VCPU * vcpu, INST64 inst)
{
	// I26 and M29 are identical for these fields
	u64 ar3 = inst.M29.ar3;

	if (privify_en && inst.M29.r2 > 63 && inst.M29.ar3 < 8) {
		// privified mov from kr
		u64 val;
		if (vcpu_get_ar(vcpu, ar3, &val) != IA64_ILLOP_FAULT)
			return vcpu_set_gr(vcpu, inst.M29.r2 - 64, val, 0);
		else
			return IA64_ILLOP_FAULT;
	} else {
		u64 r2 = vcpu_get_gr(vcpu, inst.M29.r2);
		return vcpu_set_ar(vcpu, ar3, r2);
	}
}

/********************************
 * Moves to privileged registers
********************************/

static IA64FAULT priv_mov_to_pkr(VCPU * vcpu, INST64 inst)
{
	u64 r3 = vcpu_get_gr(vcpu, inst.M42.r3);